diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f50ed36e1..52e8b5b059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Fixed an SQL error that occurred when duplicating variants. ([#3727](https://github.com/craftcms/commerce/issues/3727)) +- Fixed a PHP error that could occur when completing an order. ([#3733](https://github.com/craftcms/commerce/issues/3733)) ## 5.2.0 - 2024-10-16 diff --git a/src/services/LineItems.php b/src/services/LineItems.php index c8a65c7142..e7627fde24 100644 --- a/src/services/LineItems.php +++ b/src/services/LineItems.php @@ -520,7 +520,7 @@ public function eagerLoadLineItemsForOrders(array $orders): array public function orderCompleteHandler(LineItem $lineItem, Order $order): void { // Called the after order complete method for the purchasable if there is one - if ($lineItem->getPurchasable()) { + if ($lineItem->type === LineItemType::Purchasable && $lineItem->getPurchasable()) { $lineItem->getPurchasable()->afterOrderComplete($order, $lineItem); }