chengwl hai 6 horas
pai
achega
94fa5ac41e
Modificáronse 1 ficheiros con 15 adicións e 0 borrados
  1. 15 0
      packages/Webkul/BagistoApi/src/State/CartTokenProcessor.php

+ 15 - 0
packages/Webkul/BagistoApi/src/State/CartTokenProcessor.php

@@ -907,9 +907,24 @@ class CartTokenProcessor implements ProcessorInterface
             \Webkul\Shipping\Facades\Shipping::collectRates();
         }
 
+        $cartId = $cart->id;
+
         CartFacade::collectTotals();
 
         $cart = CartFacade::getCart();
+
+        /**
+         * When cart has no items, some flows may leave facade cart as null
+         * after totals collection. Fallback to DB lookup by original cart id.
+         */
+        if (! $cart && $cartId) {
+            $cart = CartModel::find($cartId);
+        }
+
+        if (! $cart) {
+            throw new ResourceNotFoundException(__('bagistoapi::app.graphql.cart.cart-not-found'));
+        }
+
         $cart->load('items.product');
 
         $cartData = CartData::fromModel($cart);