Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
107 stars 20 forks source link

Filtered currency improperly limiting available services after refetching #1312

Open dechov opened 6 years ago

dechov commented 6 years ago

Reported in support forum thread: https://wordpress.org/support/topic/woo-services-canada-post-shipping-problem/

There appears to be a potential compatibility issue with plugins that filter woocommerce_currency, such as Currency Switcher for WooCommerce. The configured shipping method is disappearing after a day, likely because a customer session (in which the currency is filtered to USD) is triggering a scheduled service settings fetch. The proper shipping method becomes available once again upon saving the settings, which forces another service settings fetch.

Should we be using the unfiltered currency, or is there another way we might want to address this?

kschmidtdev commented 6 years ago

Is there any update on this? I am unable to use Canada Post as a shipping option when the store currency is USD.

jeffstieler commented 6 years ago

I have not been able to reproduce this. @dechov were you able to?

I suspect just using get_option( 'woocommerce_currency' ) instead of get_woocommerce_currency() be a safe "fix", but I'd like to verify it's actually fixing something.

Edit: I've tried having the cron schema fetch get kicked off from a customer session that has selected USD on a store with a default currency of CAD. No luck in getting the schemas to change to USD..

dechov commented 5 years ago

Sorry for the delay – I'd come up with these testing instructions:

  1. Configure Currency Switcher for Woo with a currency for your country (e.g. INR) that is different from the store country (e.g. USD)
  2. Enable frequent fetch: define( 'WOOCOMMERCE_CONNECT_FREQUENT_FETCH', true );
  3. Load a front-end page
  4. Disable frequent fetch
  5. Check the "Add shipping method" options (on a shipping zone screen), and confirm that they match the services for the filtered country (e.g. no USPS), not the saved store country (e.g. USPS)

Tried testing earlier, and (besides failing to follow my own testing instructions) I ran into some caching of the currency that appeared on the front-end, making it unresponsive to changes to Currency Switcher settings.

Now that the currency has switched (possibly due to restarting my VM), I am able to reproduce the issue using the instructions above. get_option sounds fine to me, unless of course there are other cases where we wouldn't want to bypass filters on the currency.

aheckler commented 3 years ago

3753842-zen