fixed checkout service
This commit is contained in:
parent
622901eaf5
commit
95ad14093a
|
|
@ -15,8 +15,16 @@ class ProductSku extends Base
|
|||
'images' => 'array',
|
||||
];
|
||||
|
||||
protected $appends = ['image'];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function getImageAttribute()
|
||||
{
|
||||
$images = $this->images ?? [];
|
||||
return $images[0] ?? '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ class CartDetail extends JsonResource
|
|||
'product_id' => $this->product_id,
|
||||
'sku_id' => $this->product_sku_id,
|
||||
'name' => $description->name,
|
||||
'image' => image_resize($sku->image),
|
||||
'image' => $sku->image,
|
||||
'image_url' => image_resize($sku->image),
|
||||
'quantity' => $this->quantity,
|
||||
'selected' => $this->selected,
|
||||
'price' => $price,
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ class CartService
|
|||
return $description && $product;
|
||||
});
|
||||
|
||||
$cartList = CartDetail::collection($cartItems)->jsonSerialize();
|
||||
return $cartList;
|
||||
return CartDetail::collection($cartItems)->jsonSerialize();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@
|
|||
|
||||
namespace Beike\Shop\Services;
|
||||
|
||||
use Beike\Models\Cart;
|
||||
use Beike\Models\CartProduct;
|
||||
use Beike\Models\Customer;
|
||||
use Beike\Models\Order;
|
||||
use Beike\Repositories\CartRepo;
|
||||
use Beike\Repositories\OrderRepo;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Beike\Repositories\PluginRepo;
|
||||
use Beike\Repositories\AddressRepo;
|
||||
use Beike\Repositories\CountryRepo;
|
||||
|
|
@ -81,9 +79,15 @@ class CheckoutService
|
|||
$checkoutData = self::checkoutData();
|
||||
$checkoutData['customer'] = $customer;
|
||||
|
||||
$order = OrderRepo::create($checkoutData);
|
||||
|
||||
CartRepo::clearSelectedCartProducts($customer);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$order = OrderRepo::create($checkoutData);
|
||||
CartRepo::clearSelectedCartProducts($customer);
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
dd($e);
|
||||
}
|
||||
|
||||
// Notification::endmail();
|
||||
// Notification::sendsms();
|
||||
|
|
|
|||
Loading…
Reference in New Issue