programing

청구 필드를 삭제할 때 WooCommerce 오류가 발생했습니다. "계속하려면 주소를 입력하십시오."

golfzon 2023. 4. 4. 22:39
반응형

청구 필드를 삭제할 때 WooCommerce 오류가 발생했습니다. "계속하려면 주소를 입력하십시오."

WooCommerce 체크아웃 페이지의 청구 필드를 삭제했습니다.다음 행을 에 추가했습니다.functions.php:

add_filter("woocommerce_checkout_fields", "remove_billing_fields");
function remove_billing_fields($fields) {
    unset($fields["billing"]["billing_first_name"]);
    unset($fields["billing"]["billing_last_name"]);
    unset($fields["billing"]["billing_company"]);
    unset($fields["billing"]["billing_address_1"]);
    unset($fields["billing"]["billing_address_2"]);
    unset($fields["billing"]["billing_city"]);
    unset($fields["billing"]["billing_postcode"]);
    unset($fields["billing"]["billing_country"]);
    unset($fields["billing"]["billing_state"]);
    unset($fields["billing"]["billing_email"]);
    unset($fields["billing"]["billing_phone"]);
    return $fields;
}

그러면 과금 필드가 삭제되고 필요에 따라 배송 필드가 그대로 유지됩니다.그러나 체크아웃 시 오류가 나타납니다.

Please enter an address to continue.

단, 배송 필드는 모두 입력되어 있습니다.요구가 AJAX 경유로 송신되고 있습니다( )/shop/checkout?wc-ajax=checkout) 요구를 검사하면, 다음의 필드가 송신되고 있는 것을 알 수 있습니다.

billing_email:john@example.com
shipping_first_name:John
shipping_last_name:Doe
shipping_address_1:123 Easy St
shipping_address_2:
shipping_country:US
shipping_state:NY
shipping_city:New York
shipping_postcode:12345
billing_phone:123-456-7890
payment_method:stripe
wc-stripe-payment-token:abc123
_wpnonce:abc123
_wp_http_referer:/shop/checkout

청구필드가 설정되어 있을 때는 요구가 진행되기 때문에 다른 것은 모두 올바르게 설정되어 있다고 생각합니다.왜 이 오류가 발생하는지 아십니까?

내가 찾은 건 비록 내가 숨길 수 있지만billing_country이 필드는 기본적으로 배송 필드를 사용하도록 WooCommerce가 설정되어 있는 경우에도 세금과 배송료를 계산하기 위해 필요합니다.

언급URL : https://stackoverflow.com/questions/46671968/woocommerce-error-when-removing-billing-fields-please-enter-an-address-to-cont

반응형