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;
}
1 回答
有同样的问题,修复它将此代码添加到functions.php: