非ユーザーの 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->$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
}
ご協力いただきありがとうございます :)