Woocommerce Local Pickup Plus - 修改强制所有项目被拾取

问题描述:

我正在使用woocommerce的Local Pickup Plus插件,它几乎是我需要的所有东西,除了客户必须手动选择每个产品作为运输或本地取货的购物车。Woocommerce Local Pickup Plus - 修改强制所有项目被拾取

我在想,如果有一个简单的方法来迫使客户已经出货的所有项目或所有项目拿起

+0

你可以把车页面,上面写着“出货的所有项目”或“拾起的所有项目” –

+0

我可以修改该插件等等方式上的按钮,通过点击拾取选择的所有车中的物品取件? – timboon

+0

有趣,我有完全相同的问题,它不是非常强大 – Rich

我结束了写我自己的函数来解决这个只能做什么,我是专门找。此功能添加选项以从下拉列表中选择要从中取货的商店,然后相应地更新送货。

/** 
* Add store location select dropdown in checkout page 
**/ 
add_filter('woocommerce_checkout_fields' , 'custom_store_pickup_field'); 

function custom_store_pickup_field($fields) { 

     $fields['billing']['store_pickup'] = array(
     'type'  => 'select', 
     'options' => array(
     'option_0'=> 'Please Select a Delivery Option', 
     'option_1' => 'Delivery', 
     'option_2' => 'Gym1', 
     'option_3' => 'Gym2' 
     ), 
    'label'  => __('Delivery or Store Pickup', 'woocommerce'), 
    'required' => true, 
    'class'  => array('store-pickup form-row-wide'), 
    'id'  => 'store_pickup_val', 
    'clear'  => true 
    ); 


    return $fields; 
} 

//* Process the checkout 
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process'); 
function wps_select_checkout_field_process() { 
    global $woocommerce; 
    // Check if set, if its not set add an error. 
    if ($_POST['store_pickup'] == "option_0") 
    wc_add_notice('<strong>Please select a day part under Delivery options</strong>', 'error'); 
} 


add_action('woocommerce_after_checkout_form', 'gym_opening_hours', 6); 

function gym_opening_hours() { 

    ?> 
    <script type="text/javascript"> 
     jQuery('#store_pickup_val').change(function(){ 

      jQuery('body').trigger('update_checkout'); 


      jQuery(".gym-collection").remove(); 

      if (this.value == 'option_1') { 
       jQuery('#shipping_method_0_flat_rate1').prop('checked', true); 
      } 

      if (this.value == 'option_2') { 
       jQuery("<p>Order can be collected between 4pm - 7pm on Tuesdays</p>").addClass("gym-collection").insertAfter("#store_pickup_val"); 
       jQuery('#shipping_method_0_local_pickup3').prop('checked', true); 
      } 
       if (this.value == 'option_3') { 
       jQuery("<p>Order can be collected between 4pm - 7pm on Tuesdays</p>").addClass("gym-collection").insertAfter("#store_pickup_val"); 
       jQuery('#shipping_method_0_local_pickup3').prop('checked', true);   
      } 
      else { 

      } 

     }); 
    </script> 
    <?php 

} 


# add this in your plugin file and that's it, the calculate_shipping method of your shipping plugin class will be called again 
function action_woocommerce_checkout_update_order_review($array, $int) 
{ 
    WC()->cart->calculate_shipping(); 
    return; 
} 
add_action('woocommerce_checkout_update_order_review', 'action_woocommerce_checkout_update_order_review', 10, 2); 
?> 

<?php