bumbummen99/LaravelShoppingcart

The cart does not contain rowId

vdvcoder opened this issue · 2 comments

When we want to update the qty of a product and we click to fast we get the following error:

Gloudemans \ Shoppingcart \ Exceptions \ InvalidRowIDException

The cart does not contain rowId bd91f0734028f6421c5951370ce1e6ba.
 <div class="flex items-center gap-4" x-data="{rowId:'{{$item->rowId}}',qty:'{{$item->qty}}'}">
         <input x-model="qty" x-on:change="
                                            if('{{$item->model->eenheid}}' == 'ton')
                                            {
                                                if(qty > 12)
                                                {
                                                    $wire.updateItem(rowId,12); return qty = 12
                                                }
                                            }else{if('{{$item->model->eenheid}}' == 'm²')
                                            {
                                                if(qty < 10)
                                                {
                                                    $wire.updateItem(rowId,10); return qty = 10
                                                }
                                            }}
                                            ;
                                            $wire.updateItem(rowId,qty);"
                                           type="number"
                                           @if($item->model->eenheid == "m²")
                                                min="10"
                                           @elseif($item->model->product->category->id == 18)
                                               step="1"
                                                min="1"
                                                max="8"
                                           @elseif($item->model->product->eenheid == "m³")
                                                step="0.5"
                                                min="1"
                                           @elseif($item->model->product->eenheid == "m³")
                                                step="0.5"
                                                min="1"
                                           @elseif($item->model->product->eenheid == "ton")
                                                step="0.5"
                                                max="12"
                                           @else
                                                min="1"
                                                step="1"
                                           @endif
                                           :value="qty" class="border-2 border-subColor p-2 text-center w-full max-w-[120px]"
                 >
     ...
</div>
 public function updateItem($rowId,$qty)
    {
        
        Cart::update($rowId, (float)$qty);
        ....
   }

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

Are you using store/restore? Maybe you have 2 concurrent requests so the second one cant load the cart.