query('coupon_code'); if ($couponCode) { $coupon = Coupon::findByCode($couponCode); try { resolve(Pipeline::class) ->send($coupon) ->through($this->checkers) ->then(function ($coupon) use (&$cartWithCoupon) { Cart::applyCoupon($coupon); $cartWithCoupon = json_encode(Cart::instance()); Cart::removeCoupon(); }); } catch (Exception) { //Just suppressing the exception } } return $cartWithCoupon ?? Cart::instance(); } }