代码进入function.php
活动子主题(或活动主题)的文件。它可以工作。
add_filter( \'woocommerce_billing_fields\', \'woo_filter_state_billing\', 10, 1 );
function woo_filter_state_billing( $address_fields ) {
$address_fields[\'billing_state\'][\'required\'] = true;
return $address_fields;
}
add_filter( \'woocommerce_shipping_fields\', \'woo_filter_state_shipping\', 10, 1 );
function woo_filter_state_shipping( $address_fields ) {
$address_fields[\'shipping_state\'][\'required\'] = true;
return $address_fields;
}