fixed quantity 0
This commit is contained in:
parent
33a887c5f2
commit
c0603b0bb1
|
|
@ -43,7 +43,7 @@ class CartController extends Controller
|
|||
public function update(Request $request, $cartId): array
|
||||
{
|
||||
$customer = current_customer();
|
||||
$quantity = $request->get('quantity');
|
||||
$quantity = (int)$request->get('quantity');
|
||||
CartService::updateQuantity($customer, $cartId, $quantity);
|
||||
|
||||
return CartService::reloadData();
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ class CartService
|
|||
$productId = $sku->product_id;
|
||||
$skuId = $sku->id;
|
||||
|
||||
if (empty($sku)) {
|
||||
throw new Exception("无效的SKU ID");
|
||||
if (empty($sku) || $quantity == 0) {
|
||||
return null;
|
||||
}
|
||||
$cart = Cart::query()
|
||||
->where('customer_id', $customerId)
|
||||
|
|
@ -96,7 +96,7 @@ class CartService
|
|||
*/
|
||||
public static function updateQuantity($customer, $cartId, $quantity)
|
||||
{
|
||||
if (empty($cartId)) {
|
||||
if (empty($cartId) || $quantity == 0) {
|
||||
return;
|
||||
}
|
||||
Cart::query()->where('customer_id', $customer->id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue