fixed checkout
This commit is contained in:
parent
03e285239c
commit
6cbd4d80de
|
|
@ -17,14 +17,18 @@ class CartRepo
|
||||||
{
|
{
|
||||||
public static function createCart(int $customerId)
|
public static function createCart(int $customerId)
|
||||||
{
|
{
|
||||||
|
$customer = CustomerRepo::find($customerId);
|
||||||
$cart = Cart::query()->where('customer_id', $customerId)->first();
|
$cart = Cart::query()->where('customer_id', $customerId)->first();
|
||||||
if (empty($cart)) {
|
if (empty($cart)) {
|
||||||
|
$shippingMethod = PluginRepo::getShippingMethods()->first();
|
||||||
|
$paymentMethod = PluginRepo::getPaymentMethods()->first();
|
||||||
|
$defaultAddress = AddressRepo::listByCustomer($customer)->first();
|
||||||
$cart = Cart::query()->create([
|
$cart = Cart::query()->create([
|
||||||
'customer_id' => $customerId,
|
'customer_id' => $customerId,
|
||||||
'shipping_address_id' => 0,
|
'shipping_address_id' => $defaultAddress->id,
|
||||||
'shipping_method_code' => '',
|
'shipping_method_code' => $shippingMethod->code,
|
||||||
'payment_address_id' => 0,
|
'payment_address_id' => $defaultAddress->id,
|
||||||
'payment_method_code' => ''
|
'payment_method_code' => $paymentMethod->code
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return $cart;
|
return $cart;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue