woocommerce/woocommerce

woocommerce_shipping_calculator_enable_country Filter breaks Shipping Calculator

オープン

#27,491 opened on 2020/08/26

 (6 件のコメント) (0 件のリアクション) (0 人の担当者)PHP (10,695 件のフォーク)batch import
CheckoutEnhancementEscargotGood First Issueneeds: engineeringplugin: woocommerce

Repository metrics

Stars
 (10,294 個のスター)
PR merge metrics
 (平均マージ 9d 12h) (30d で 423 merged PRs)

説明

The Shipping Calculator on the Basket page allows users to see if a shipping option is available for their address.

This form by default asks for City, State, Country, Postcode

City, State and Country have filters available to remove these fields, suggesting it's OK to only require a Postcode. These filters are:

woocommerce_shipping_calculator_enable_city woocommerce_shipping_calculator_enable_state woocommerce_shipping_calculator_enable_country

Removing the city and state work well but when removing country the shipping calculator always returns the "No shipping options were found" message.

Looking at the calculate_shipping() function from line 23 of woocommerce/includes/shortcodes/class-wc-shortcode-cart.php file I can see that the set_shipping_location() function is only triggered if a country variable is set.

Therefore woocommerce_shipping_calculator_enable_country doesn't work but if we use it it breaks the shipping calculator. Perhaps this filter should only work if the store has set only one purchasing country. And a check within the calculate_shipping() function could determine this and automatically set the country variable from the admin settings and the single country that has been set. This would allow single country stores to make use of this "woocommerce_shipping_calculator_enable_country" filter correctly and remove the country dropdown, which is appropriate for single country store as the field is unnecessary.

Thank you.

コントリビューターガイド