From 7634b6b77096071644439b3716ce2c7b9872d944 Mon Sep 17 00:00:00 2001 From: Steve <34465153+xxl4@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:09:07 +0800 Subject: [PATCH] when cart have coupon code and don't support upselling --- src/Upselling.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Upselling.php b/src/Upselling.php index c222d37..e9239d2 100644 --- a/src/Upselling.php +++ b/src/Upselling.php @@ -70,9 +70,13 @@ public function applyUpselling($cart) { 'status' => 'processing', 'created_at' => ['>=', now()->subDay()] ]); - //order findwhere created_at >= now()->subDay() - if($processingOrder && !empty($cart->customer_email)) { - //Log::info('Processing order found '.json_encode($processingOrder)); + + // check the cart have coupon code + if($cart->coupon_code) { + $this->coupon_code = $cart->coupon_code; + } + + if($processingOrder && !empty($cart->customer_email) && empty($cart->coupon_code)) { Cart::saveShippingMethod('free_free'); @@ -82,13 +86,10 @@ public function applyUpselling($cart) { Cart::setCouponCode($coupon_code)->collectTotals(); } - Cart::collectTotals(); Log::info('Processing order cart found '.json_encode($cart)); } - - } /**