Skip to content

Commit

Permalink
Fix class_implements error on string 'product_variant' (#1964)
Browse files Browse the repository at this point in the history
fixes #1942 

fix `class_implements` error on string 'product_variant'

Co-authored-by: Alec Ritson <[email protected]>
  • Loading branch information
wychoong and alecritson authored Oct 21, 2024
1 parent ab7f6d5 commit ac92f14
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 ac92f14

Please sign in to comment.