2017-10-10 107 views
1

的WooCommerce結帳頁面上我已經刪除計費領域通過添加以下行functions.phpWooCommerce在刪除結算字段時出錯:「請輸入地址以繼續。」

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:[email protected] 
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 

注意,請求不經過時計費字段設置,所以我相信一切設置正確。任何想法爲什麼這個錯誤被拋出?

+0

我已經用WooCommerce 3.12版上的代碼進行了一些測試,並且我沒有遇到這個問題。 – LoicTheAztec

回答

1

我發現雖然我可以隱藏billing_country字段,但即使WooCommerce配置爲默認使用運輸字段,也需要計算稅金和運費。