woocommerce仅在签出时预填充国家/地区
我只想在woocommerce签出中为非用户预填充国家/地区字段。所以这两个过滤器是分开工作的,而不是一起工作的,我可以将它们组合在一起吗woocommerce仅在签出时预填充国家/地区,woocommerce,checkout,woocommerce-checkout-fields,Woocommerce,Checkout,Woocommerce Checkout Fields,我只想在woocommerce签出中为非用户预填充国家/地区字段。所以这两个过滤器是分开工作的,而不是一起工作的,我可以将它们组合在一起吗 add_filter('woocommerce_checkout_get_value', function($input, $key) { global $current_user; // Return the user property if it exists, false otherwise return ($current_user->$
add_filter('woocommerce_checkout_get_value', function($input, $key) {
global $current_user;
// Return the user property if it exists, false otherwise
return ($current_user->$key
? $current_user->$key
: false
);
}, 10, 2);
使用此过滤器,我尝试将国家设置为默认值,但它会被上面的函数覆盖
add_filter( 'default_checkout_country', 'change_default_checkout_country' );
function change_default_checkout_country() {
return 'DE'; // country code
}
谢谢你的帮助:)