因此,我想根据运输方式取消设置一些帐单字段,但是除非重新加载整个结帐页面,否则它不会起作用。如何使用AJAX重新加载帐单字段?
/*
* Remove fields for chosen shipping method
*/
add_filter( 'woocommerce_checkout_fields', 'awoohc_override_checkout_fields' );
function awoohc_override_checkout_fields( $fields ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
if ( 'local_pickup:4' === $chosen_methods[0] ) {
unset( $fields['billing']['billing_address_1'] );
unset( $fields['billing']['billing_address_2'] );
}
return $fields;
}