【问题标题】:Woocommerce show / hide required checkout fields with using of Local pickup plus pluginWoocommerce 使用本地取货加插件显示/隐藏必填结帐字段
【发布时间】:2017-05-25 09:11:25
【问题描述】:

Woocommerce 本地取货加插件与“隐藏送货地址”选项一起使用。当一些必需的送货地址字段被隐藏时,它们仍按要求设置,无法填写表格。 那么如果选择了本地取货,如何取消设置必填字段选项呢?

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    遇到了同样的问题,将其添加到functions.php中修复它:

    add_filter('woocommerce_checkout_fields', 'plus_remove_shipping_checkout_fields');
    
    function plus_remove_shipping_checkout_fields($fields) {
        $shipping_method ='local_pickup_plus'; // Set the desired shipping method to hide the checkout field(s).
        global $woocommerce;
        $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
        $chosen_shipping = $chosen_methods[0];
    
        if ($chosen_shipping == $shipping_method) {
            unset($fields['shipping']['shipping_address_1']); // Add/change filed name to be hide
            unset($fields['shipping']['shipping_address_2']);
        }
        return $fields;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-01-13
      • 2020-12-12
      • 1970-01-01
      • 2015-07-09
      • 2019-01-21
      • 2019-06-19
      • 1970-01-01
      • 2018-05-23
      • 2017-07-25
      相关资源
      最近更新 更多