Skip to content

Refuse to delete a currency that orders were placed in - #1125

Open
KrzysztofPajak wants to merge 1 commit into
developfrom
fix/currency-used-by-orders
Open

KrzysztofPajak wants to merge 1 commit into
developfrom
fix/currency-used-by-orders

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Issue

An order keeps the code of the currency it was placed in. After an admin deleted that currency:

  • the order's edit page in the admin and in the store panel failed with a 500 (Cannot load order currency);
  • completing or cancelling the order failed where loyalty points are converted (ConvertToPrimaryStoreCurrency refuses a missing currency).

Solution

ValidateCurrencyDelete now refuses a currency that any order was placed in, next to the existing refusals for the primary and the exchange-rate currency. The admin is told to unpublish it instead. The check is one paged query (GetOrderQuery gained a CustomerCurrencyCode filter, read with PageSize = 1).

An installation that already deleted such a currency gets its orders back by creating the currency again with the same code; it can stay unpublished.

New resource Admin.Configuration.Currencies.CantDeleteUsedByOrders in DefaultLanguage.xml and Upgrade/en_250.xml.

Breaking changes

A currency used by orders can no longer be deleted.

Testing

  1. Switch the storefront to EUR and place an order.
  2. In the admin, delete EUR: the page stays on the currency with "Orders were placed in this currency, so it can't be deleted. Unpublish it instead."
  3. Delete a currency no order uses (for example GBP): it is deleted.
  4. The EUR order opens in the admin.

Tests: CurrencyViewModelServiceTests (refused when orders use it) and GetOrderQueryHandlerTests (the new filter).

An order keeps the code of the currency it was placed in. Once that currency was deleted, the
order's edit page in the admin and the store panel failed with a 500, and completing or
cancelling the order failed where loyalty points are converted. The currency now cannot be
deleted while an order uses it; it can be unpublished instead. An installation that already
deleted one gets its orders back by creating the currency again with the same code.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants