From 8dd3edbc1c92e07e5c386480ac6875ad9b0dbda4 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Wed, 16 Sep 2026 09:07:06 +0100 Subject: [PATCH 1/2] #4368 order condition rules could show incorrect currency --- CHANGELOG.md | 4 ++++ .../orders/OrderCurrencyValuesAttributeConditionRule.php | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53d6661684..6c4bdb0671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft Commerce +## Unreleased + +- Fixed a bug where currency-based order condition rules could show the incorrect currency. ([#4368](https://github.com/craftcms/commerce/issues/4368)) + ## 5.7.4 - 2026-09-15 - Fixed a bug where custom order fields with a visibility condition based on order attributes couldn’t be saved. ([#4198](https://github.com/craftcms/commerce/issues/4198)) diff --git a/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php b/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php index da52e79b67..02425daa95 100644 --- a/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php +++ b/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php @@ -17,6 +17,7 @@ use craft\elements\conditions\ElementConditionInterface; use craft\fields\conditions\MoneyFieldConditionRule; use craft\fields\Money; +use craft\helpers\Cp; use craft\models\Site; use Money\Currency; use yii\db\QueryInterface; @@ -72,9 +73,13 @@ public function setCondition(ConditionInterface $condition): void $this->currency = $this->getCondition()->getStore()->getCurrency(); } else { /** @var Site|StoreBehavior|null $currentSite */ - $currentSite = Craft::$app->getSites()->getCurrentSite(); + if (Craft::$app->getRequest()->getIsCpRequest()) { + $currentSite = Cp::requestedSite(); + } else { + $currentSite = Craft::$app->getSites()->getCurrentSite(); + } - if ($currentSite->getBehavior(StoreBehavior::class)) { + if ($currentSite->getBehavior('commerce:store')) { $this->currency = $currentSite?->getStore()->getCurrency(); } } From 63114b55124dfcdc3198afd72307430e5d5fe937 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Wed, 16 Sep 2026 09:10:02 +0100 Subject: [PATCH 2/2] phpstan fix --- .../orders/OrderCurrencyValuesAttributeConditionRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php b/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php index 02425daa95..bd0d3fcd66 100644 --- a/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php +++ b/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php @@ -72,12 +72,12 @@ public function setCondition(ConditionInterface $condition): void if ($this->getCondition() instanceof HasStoreInterface) { $this->currency = $this->getCondition()->getStore()->getCurrency(); } else { - /** @var Site|StoreBehavior|null $currentSite */ if (Craft::$app->getRequest()->getIsCpRequest()) { $currentSite = Cp::requestedSite(); } else { $currentSite = Craft::$app->getSites()->getCurrentSite(); } + /** @var Site|StoreBehavior|null $currentSite */ if ($currentSite->getBehavior('commerce:store')) { $this->currency = $currentSite?->getStore()->getCurrency();