chengwl 1 week ago
parent
commit
9d39dfcc77
1 changed files with 8 additions and 5 deletions
  1. 8 5
      packages/Webkul/BagistoApi/src/Services/PaymentService.php

+ 8 - 5
packages/Webkul/BagistoApi/src/Services/PaymentService.php

@@ -79,13 +79,16 @@ class PaymentService
         if ($express) {
             $this->validateExpressInitiation($cart, $input);
         } else {
-              if ($input->shippingMethod) {
-                if (! Cart::saveShippingMethod($input->shippingMethod)) {
-                    throw new OperationFailedException(__('bagistoapi::app.graphql.checkout.shipping-method-save-failed'));
-                }
+            if(!$cart->shipping_method){
+                if ($input->shippingMethod) {
+                    if (! Cart::saveShippingMethod($input->shippingMethod)) {
+                        throw new OperationFailedException(__('bagistoapi::app.graphql.checkout.shipping-method-save-failed'));
+                    }
                 }
+            }
             $this->validateStandardInitiation($cart, $input);
             Cart::collectTotals();
+            $cart = Cart::getCart();
         }
 
       
@@ -98,7 +101,7 @@ class PaymentService
             if (! Cart::savePaymentMethod(['method' => $input->paymentMethod])) {
                 throw new OperationFailedException(__('bagistoapi::app.graphql.checkout.payment-method-save-failed'));
             }
-            Cart::collectTotals();
+            // Cart::collectTotals();
             $cart = Cart::getCart();
         }