【发布时间】:2018-05-24 02:38:54
【问题描述】:
in WooCommerce, I am trying to hide the company name field whenever "delivery to home" is selected.我尝试了很多不同的东西。
这是我最后一次尝试:
add_filter('woocommerce_checkout_fields', 'xa_remove_billing_checkout_fields');
function xa_remove_billing_checkout_fields($fields) {
$shipping_method ='pakkelabels_shipping_gls1'; // 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['billing']['billing_company']); // Add/change filed name to be hide
}
return $fields;
}
但它所做的只是将航运公司从第一个字段移到最后一个字段。
如何根据选择的送货方式有条件地隐藏特定的结帐字段?
【问题讨论】:
标签: php jquery wordpress woocommerce shipping