Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
The variant on a LineItem is often an array (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Nov 28, 2023
1 parent 84e1eec commit 23a1a9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Listeners/ProcessCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function handle(OrderStatusUpdated $event)
$product = $lineItem->product();

if ($product->purchasableType() === ProductType::Variant) {
$productVariant = $product->variant($lineItem->variant());
$productVariant = $product->variant($lineItem->variant()['variant'] ?? $lineItem->variant());

return $productVariant->has('is_digital_product')
? $productVariant->get('is_digital_product')
Expand Down
5 changes: 4 additions & 1 deletion tests/Listeners/ProcessCheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ public function can_process_checkout_with_variant_product()
'id' => Stache::generateId(),
'product' => $product->id(),
'quantity' => 1,
'variant' => 'Red_Small',
'variant' => [
'variant' => 'Red_Small',
'product' => $product->id(),
],
'total' => 1200,
],
])
Expand Down

0 comments on commit 23a1a9a

Please sign in to comment.