diff --git a/CHANGELOG.md b/CHANGELOG.md index 155ab75be4..cc5ce444f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Fixed a PHP error that could occur on Edit Plan pages. ([#3998](https://github.com/craftcms/commerce/issues/3998)) +- Fixed a PHP error that could occur when upgrading to Commerce 5. ([#3933](https://github.com/craftcms/commerce/pull/3933)) ## 5.3.11 - 2025-05-01 diff --git a/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php b/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php index 8c0ccfb989..6fff3f5ebf 100644 --- a/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php +++ b/src/elements/conditions/orders/OrderCurrencyValuesAttributeConditionRule.php @@ -65,7 +65,10 @@ public function setCondition(ConditionInterface $condition): void } else { /** @var Site|StoreBehavior|null $currentSite */ $currentSite = Craft::$app->getSites()->getCurrentSite(); - $this->currency = $currentSite?->getStore()->getCurrency(); + + if ($currentSite->getBehavior(StoreBehavior::class)) { + $this->currency = $currentSite?->getStore()->getCurrency(); + } } if ($this->currency) { @@ -80,7 +83,7 @@ protected function field(): FieldInterface { // Mock a Money field $field = new Money(); - $field->currency = $this->currency?->getCode(); + $field->currency = $this->currency?->getCode() ?? $field->currency; return $field; }