From bca2c69a88f2723ad085be4c46d4104348b8ea0f Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Sat, 12 Oct 2024 22:15:23 +1100 Subject: [PATCH] Fix an error when creating custom line items --- src/services/Codes.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/services/Codes.php b/src/services/Codes.php index de81924..ecd50fd 100755 --- a/src/services/Codes.php +++ b/src/services/Codes.php @@ -18,6 +18,7 @@ use craft\models\FieldLayout; use craft\commerce\elements\Order; +use craft\commerce\enums\LineItemType; use craft\commerce\models\LineItem; use yii\base\Component; @@ -242,6 +243,11 @@ public function handleValidateLineItem(ModelEvent $event): void { /** @var LineItem $lineItem */ $lineItem = $event->sender; + + if ($lineItem->type === LineItemType::Custom) { + return; + } + $purchasable = $lineItem->getPurchasable(); // make sure it's a Voucher