Skip to content

Commit 8e0d31e

Browse files
committed
Stage 5i: migrate CatalogPricingRule + post-Stage 5 fixes
CatalogPricingRule moves to src/: - craft\commerce\models\CatalogPricingRule → CraftCms\Commerce\Catalog\Models\CatalogPricingRule Key swaps: - craft\base\Model → CraftCms\Cms\Component\Component - Yii2 defineRules() → Laravel getRules() with Rule::in() for 'apply' - I18N::getFormatter()->asPercent() / Conditions::createCondition() facades - CraftCms\Cms\Support\Json::decodeIfJson() Post-Stage 5 fixes: - Fix infinite recursion in ShippingMethodOrderCondition, ShippingRuleOrderCondition, DiscountOrderCondition config() methods. $this->toArray(['storeId']) was calling getObjectVars() which triggers the PHP 8.4 $config property hook getter, recursing into config(). Replaced with explicit ['storeId' => $this->storeId]. Also adds CraftCms\Commerce\Base\EnumHelpersTrait (companion to the Stage 1 enums, missed at the time) and the WIP changelog covering stages 1–5. Legacy CatalogPricingRule becomes a class_alias stub.
1 parent 6ea808b commit 8e0d31e

7 files changed

Lines changed: 693 additions & 524 deletions

File tree

CHANGELOG-WIP.md

Lines changed: 307 additions & 0 deletions
Large diffs are not rendered by default.

src-yii2/elements/conditions/orders/DiscountOrderCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function defineRules(): array
3434
*/
3535
protected function config(): array
3636
{
37-
return array_merge(parent::config(), $this->toArray(['storeId']));
37+
return array_merge(parent::config(), ['storeId' => $this->storeId]);
3838
}
3939

4040
/**

src-yii2/elements/conditions/orders/ShippingMethodOrderCondition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ShippingMethodOrderCondition extends OrderCondition implements HasStoreInt
3131
/**
3232
* @inheritdoc
3333
*/
34-
protected function defineRules(): array
34+
public function defineRules(): array
3535
{
3636
$rules = parent::defineRules();
3737
$rules[] = [['storeId'], 'safe'];
@@ -44,7 +44,7 @@ protected function defineRules(): array
4444
*/
4545
protected function config(): array
4646
{
47-
return array_merge(parent::config(), $this->toArray(['storeId']));
47+
return array_merge(parent::config(), ['storeId' => $this->storeId]);
4848
}
4949

5050
/**

src-yii2/elements/conditions/orders/ShippingRuleOrderCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function defineRules(): array
4444
*/
4545
protected function config(): array
4646
{
47-
return array_merge(parent::config(), $this->toArray(['storeId']));
47+
return array_merge(parent::config(), ['storeId' => $this->storeId]);
4848
}
4949

5050
/**

0 commit comments

Comments
 (0)