Skip to content

Commit

Permalink
fix the coupon code
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Feb 26, 2025
1 parent 6683fdc commit 04b48f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
14 changes: 13 additions & 1 deletion src/Docs/V1/Shop/Controllers/Customer/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,12 @@ public function moveToWishlist()
* property="code",
* type="string",
* example="FLAT10"
* )
* ),
* @OA\Property(
* property="cart_id",
* type="integer",
* example=1
* ),
* )
* )
* ),
Expand Down Expand Up @@ -559,6 +564,13 @@ public function applyCoupon()
* summary="Remove cart coupon",
* description="Remove cart coupon",
* security={ {"sanctum": {} }},
*
* @OA\RequestBody(
* @OA\Property(
* property="cart_id",
* type="integer",
* example=1
* ),
*
* @OA\Response(
* response=200,
Expand Down
18 changes: 12 additions & 6 deletions src/Http/Controllers/Api/V1/Shop/Customer/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ public function store($productId): JsonResponse
], 400);
}
}
public function add($product_id)
{
print_r(123);exit;
}


/**
* Updates the quantity of the items present in the cart.
Expand Down Expand Up @@ -263,6 +258,11 @@ public function empty()
public function applyCoupon(Request $request)
{
$couponCode = $request->code;
$cart_id = $request->input("cart_id");
if($cart_id) {
$cart = $this->cartRepository->find($cart_id);
Cart::setCart($cart);
}

try {
if (strlen($couponCode)) {
Expand Down Expand Up @@ -296,8 +296,14 @@ public function applyCoupon(Request $request)
*
* @return \Illuminate\Http\Response
*/
public function removeCoupon()
public function removeCoupon(Request $request)
{
$cart_id = $request->input("cart_id");
if($cart_id) {
$cart = $this->cartRepository->find($cart_id);
Cart::setCart($cart);
}

Cart::removeCouponCode()->collectTotals();

$cart = Cart::getCart();
Expand Down

0 comments on commit 04b48f0

Please sign in to comment.