Skip to content

Commit

Permalink
Update OrderLineObserver.php
Browse files Browse the repository at this point in the history
  • Loading branch information
wychoong authored Sep 23, 2024
1 parent 4aad66d commit abfdeb5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/Observers/OrderLineObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ public function creating(OrderLine $orderLine)
*/
public function updating(OrderLine $orderLine)
{
if (! in_array(Purchasable::class, class_implements($orderLine->purchasable_type, true))) {
throw new NonPurchasableItemException($orderLine->purchasable_type);
$purchasableModel = class_exists($orderLine->purchasable_type) ?
$orderLine->purchasable_type :
Relation::getMorphedModel($orderLine->purchasable_type);

if (! $purchasableModel || ! in_array(Purchasable::class, class_implements($purchasableModel, true))) {
throw new NonPurchasableItemException($purchasableModel);
}
}
}

0 comments on commit abfdeb5

Please sign in to comment.