Woocommerce Local pickup plus plugin is used with "Hide the shipping address" option. When some required shipping address fields are hidden they are still set as required and the form cannot be completed. So how to unset the required shipping fields option in case of local pickup is selected?
1
votes
1 Answers
0
votes
Had the same issue, fixed it adding this code to 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;
}