Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order Update API Returns Total in USD Instead of INR #10282

Open
AnirudhBhat opened this issue Jan 31, 2025 · 1 comment
Open

Order Update API Returns Total in USD Instead of INR #10282

AnirudhBhat opened this issue Jan 31, 2025 · 1 comment
Labels
focus: multi-currency priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.

Comments

@AnirudhBhat
Copy link

Describe the bug

In this scenario, the store's default currency is USD, but the order was originally created in INR.

When updating the same order via the WooCommerce REST API (PUT /wp-json/wc/v3/orders/{order_id}/), the response incorrectly returns the total in USD instead of INR, despite passing "currency": "INR" in the request. This issue seems specific to INR, as the API appears to handle other currencies (e.g., EUR) correctly.

To Reproduce

  1. Create an order in WooCommerce with currency set to INR (either manually or via API).
  2. Update the order using the REST API, modifying a field like status or line_items, while also explicitly setting "currency": "INR".
  3. Observe the API response – the currency field updates to INR, but the total remains in USD instead of being converted.

Example API Request

PUT Request to Update an Order

curl -X "PUT" "/wp-json/wc/v3/orders/{order_id}" \
     -H "Authorization: Basic <CREDENTIALS>" \
     -H "Content-Type: application/json" \
     --data '{
       "status": "pending",
       "currency": "INR",
       "line_items": [
         {
           "id": 241,
           "quantity": 2
         }
       ]
     }'

Expected Behavior

The API should return a response where:

  1. The currency is "INR".
  2. The total, subtotal, and total_tax are recalculated and returned in INR.

Example Expected Response:

{
  "id": 1600,
  "status": "pending",
  "currency": "INR",
  "total": "8,300.00",
  "total_tax": "500.00",
  "line_items": [
    {
      "id": 241,
      "quantity": 2,
      "subtotal": "4,000.00",
      "total": "4,000.00"
    }
  ]
}

Actual Response (Bug)
The API response returns the total in USD, even though the currency field is set to INR.

Example Buggy Response:

{
  "id": 1600,
  "status": "pending",
  "currency": "INR",
  "total": "100.00",  // ← Still in USD instead of INR
  "total_tax": "6.00",
  "line_items": [
    {
      "id": 241,
      "quantity": 2,
      "subtotal": "50.00",
      "total": "50.00"
    }
  ]
}

Additional Observations

If an order is created with "currency": "EUR" in a store where the default currency is USD, the API correctly maintains EUR as the order's currency when updating the order via the PUT request. The totals remain in EUR without being converted back to the store’s default currency (USD).

Environment Details

WooCommerce Version: 9.7.0-dev
WooPayments Version: 8.8.0
Multi-Currency Plugin Used (if any): WooPayments built-in Multi-Currency

@AnirudhBhat AnirudhBhat added focus: multi-currency type: bug The issue is a confirmed bug. labels Jan 31, 2025
@pierorocca pierorocca added the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Jan 31, 2025
@bborman22
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: multi-currency priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.
Projects
Status: No status
Development

No branches or pull requests

3 participants