Woocommerce: Shipping calculator gets wrong country when logged in

Created on 23 May 2017  ยท  3Comments  ยท  Source: woocommerce/woocommerce

EXPLANATION OF THE ISSUE

Everything works fine when you're logged out, the problem starts when you log in, set your shipping country to A and then want to calculate shipping costs for country B in the cart.

STEPS TO REPRODUCE THE ISSUE

  1. Log in to WooCommerce store
  2. Set your country to A
  3. Add item to the cart
  4. Go to the cart
  5. Open shipping calculator
  6. Set different country than A
  7. Everything works well, shipping methods for selected country loads in
  8. Select different shipping method than default one
  9. After you click different shipping method, the whole state is being reverted to the country that you set in the shipping address details in your account.

SYSTEM STATUS

Problem occur on two instances of WooCommerce, including the clean installation with system log pasted below.


`

WordPress Environment

Home URL: http://wc.dev
Site URL: http://wc.dev
WC Version: 3.0.7
Log Directory Writable: โœ”
WP Version: 4.7.5
WP Multisite: โ€“
WP Memory Limit: 256 MB
WP Debug Mode: โ€“
WP Cron: โœ”
Language: en_US

Server Environment

Server Info: nginx/1.11.1
PHP Version: 7.0.8-2+deb.sury.org~xenial+1
PHP Post Max Size: 100 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.47.0
OpenSSL/1.0.2g

SUHOSIN Installed: โ€“
MySQL Version: 5.7.18
Max Upload Size: 100 MB
Default Timezone is UTC: โœ”
fsockopen/cURL: โœ”
SoapClient: โœ”
DOMDocument: โœ”
GZip: โœ”
Multibyte String: โœ”
Remote Post: โœ”
Remote Get: โœ”

Database

WC Database Version: 3.0.7
WC Database Prefix: wp_
woocommerce_sessions: โœ”
woocommerce_api_keys: โœ”
woocommerce_attribute_taxonomies: โœ”
woocommerce_downloadable_product_permissions: โœ”
woocommerce_order_items: โœ”
woocommerce_order_itemmeta: โœ”
woocommerce_tax_rates: โœ”
woocommerce_tax_rate_locations: โœ”
woocommerce_shipping_zones: โœ”
woocommerce_shipping_zone_locations: โœ”
woocommerce_shipping_zone_methods: โœ”
woocommerce_payment_tokens: โœ”
woocommerce_payment_tokenmeta: โœ”
MaxMind GeoIP Database: โœ”

Security

Secure connection (HTTPS): โŒYour store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
Hide errors from visitors: โœ”

Active Plugins (5)

WooCommerce PayPal Express Checkout Gateway: by WooCommerce โ€“ 1.2.1
WooCommerce Stripe Gateway: by WooCommerce โ€“ 3.1.8
WooCommerce Social Login: by SkyVerge โ€“ 2.1.0 โ€“ 2.2.0 is available
WooCommerce: by Automattic โ€“ 3.0.7
WordPress Importer: by wordpressdotorg โ€“ 0.6.3

Settings

API Enabled: โœ”
Force SSL: โ€“
Currency: EUR (โ‚ฌ)
Currency Position: right
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

WC Pages

Shop base: #4 - /sklep/
Cart: #5 - /koszyk/
Checkout: #6 - /zamowienie/
My account: #7 - /moje-konto/

Theme

Name: Storefront
Version: 2.2.0 โ€“ 2.2.2 is available
Author URL: https://woocommerce.com/
Child Theme: โŒ โ€“ If you're modifying WooCommerce on a parent theme you didn't build personally
then we recommend using a child theme. See: How to create a child theme

WooCommerce Support: โœ”

Templates

Overrides: โ€“
`

bug

Most helpful comment

I was able to reproduce this locally, and git bisect traced the issue to https://github.com/woocommerce/woocommerce/commit/d570a81241f49fb79007eba78bd0ad489d0911c1 for #13906. It looks like we're not saving the shipping info when the location in the calculator is updated, so when the fragment loads after the method is changed, it resets to the "saved" shipping location (overwriting the one they just set).

All 3 comments

Are all updates completed? Also what is the site URL?

I was able to reproduce this locally, and git bisect traced the issue to https://github.com/woocommerce/woocommerce/commit/d570a81241f49fb79007eba78bd0ad489d0911c1 for #13906. It looks like we're not saving the shipping info when the location in the calculator is updated, so when the fragment loads after the method is changed, it resets to the "saved" shipping location (overwriting the one they just set).

I have been experiencing the same issue with postal codes. The session data is overwritten by the ZIP from the saved shipping address of the logged-in user, as soon as the cart gets recalculated (e.g. by changing the selected shipping method or by reloading the page).

What info should be prioritised when proceeding to check-out (session or user data?) remains a good question though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pickplugins picture pickplugins  ยท  3Comments

pawelkmpt picture pawelkmpt  ยท  3Comments

jameskoster picture jameskoster  ยท  3Comments

richangel picture richangel  ยท  3Comments

aonzzung picture aonzzung  ยท  3Comments