设置结账时“state”字段非必填
/** * WooCommerce Extra Feature * -------------------------- * * Make "state" field not required on checkout * */ add_filter( 'woocommerce_billing_fields', 'woo_filter_state_billing', 10, 1 ); add_filter( 'woocommerce_shipping_fields', 'woo_filter_state_shipping', 10, 1 ); function woo_filter_state_billing( $address_fields ) { $address_fields['billing_state']['required'] = false; return $address_fields; } function woo_filter_state_shipping( $address_fields ) { $address_fields['shipping_state']['required'] = false; return $address_fields; }
在哪里添加此代码?
将PHP代码放在主题或子主题functions.php文件的底部。