mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
14 lines
606 B
Text
14 lines
606 B
Text
add_filter('woocommerce_checkout_fields', 'wc_remove_billing_checkout_fields');
|
|
|
|
function wc_remove_billing_checkout_fields($fields) {
|
|
$shipping_method ='free_shipping:1'; // 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_address_1']); // Add/change filed name to be hide
|
|
unset($fields['billing']['billing_address_2']);
|
|
}
|
|
return $fields;
|
|
}
|