Skip to content

Commit

Permalink
Calculate price of order item (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyfero authored Mar 21, 2024
1 parent d15a42a commit 21747de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Services/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ public function storeCartItemAsOrderItem(Order $order, CartItem $item): OrderIte
]);
}

public function storeProductAsOrderItem(Order $order, Product $product): OrderItem
public function storeProductAsOrderItem(Order $order, Product $product, ?bool $trial = false): OrderItem
{
return OrderItem::create([
'buyable_type' => Product::class,
'buyable_id' => $product->getKey(),
'name' => $product->name ?? null,
'price' => $product->price,
'price' => $trial ? 100 : $product->price,
'quantity' => 1,
'tax_rate' => $product->tax_rate,
'extra_fees' => $product->extra_fees,
'tax_rate' => $trial ? 0 : $product->tax_rate,
'extra_fees' => $trial ? 0 : $product->extra_fees,
'order_id' => $order->getKey(),
]);
}
Expand Down

0 comments on commit 21747de

Please sign in to comment.