Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
176 stars 69 forks source link

Multi-Currency: Manual Exchange Rate is not saved - Error: wcpay_multi_currency_invalid_currency_rate #6857

Closed AashikP closed 1 year ago

AashikP commented 1 year ago

Describe the bug

The manual exchange rate changes are not saved. Reloading the page shows that the exchange rate is set to Manual, but still takes the value pulled via API and sets that as the exchange rate.

To Reproduce

  1. Set store currency to Pound sterling (£)

  2. Go to WooCommerce > Settings > Multi-Currency > And add USD as an option

  3. Set the exchange rate to Manual, and save changes:

    Q8QUrw.png

  4. Find the Currency Settings updated notice.

  5. Test the updated exchange rate in cart/checkout page to find that no changes are applied to the exchange rates.

  6. Reload the page (WooCommerce > Settings > Multi-Currency) to find that the exchange rate is still set to Manual, but the rate itself is the default exchange rate pulled by API:

    jCxtu4.png

  7. Try to modify the exchange rate and save it again

  8. Do not reload the page. Save it once again to find this error in browser console:

    8UTe6Q.png

{
    "code": "wcpay_multi_currency_invalid_currency_rate",
    "message": "Invalid manual currency rate passed to update_single_currency_settings: 0",
    "data": null
}

This was the Payload sent in original request (Step 6):

q4aXlk.png

This was the Payload sent for the second request (Step 7 - without reloading the page):

WVOb4j.png

Actual behavior

Manual exchange rate request should be respected, and saved correctly.

Expected behavior

Manual exchange rates are not saved, and are lost on page reload.

Desktop (please complete the following information):

Additional context

Related ticket: 6451299-zd-woothemes Slack discussion: p1690277547352709-slack-C3NCP7ZJ6

htdat commented 1 year ago

Thanks for the report @AashikP.

This issue impacts Multi-currency, so assigning to @Automattic/sigma (based on team responsibilities Pc2DNy-3z-p2) cc @dwainm as team lead. Assigning as part of Gamma Triage process PcreKM-yM-p2.

CGA8C commented 1 year ago

We've had another report of this (6812313-zen), which led to a Duplicate Issue being created.

@dwainm do we have any idea on how deep in the backlog this is? :)

dwainm commented 1 year ago

@CGA8C thanks for the ping; this goes out with 6.5.0.