guest checkout
This commit is contained in:
parent
223aeaa46f
commit
a67b754b8f
|
|
@ -18,7 +18,7 @@ class CartController extends Controller
|
|||
->whereRelation('product', 'active', '=', true)
|
||||
->findOrFail($skuId);
|
||||
|
||||
$cart = CartService::add($customer, $sku, $quantity);
|
||||
$cart = CartService::add($sku, $quantity, $customer);
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,15 @@ class CartService
|
|||
}
|
||||
|
||||
|
||||
public static function add(Customer $customer, ProductSku $sku, int $quantity)
|
||||
public static function add($sku, int $quantity, $customer = null)
|
||||
{
|
||||
$customerId = $customer->id;
|
||||
$customerId = $customer->id ?? 0;
|
||||
$productId = $sku->product_id;
|
||||
$skuId = $sku->id;
|
||||
|
||||
if (empty($sku)) {
|
||||
throw new \Exception("无效的SKU ID");
|
||||
}
|
||||
$cart = Cart::query()
|
||||
->where('customer_id', $customerId)
|
||||
->where('product_id', $productId)
|
||||
|
|
|
|||
Loading…
Reference in New Issue