Updating line item returns no errors #1092
-
I've been scratching my head on this one for a while. In my cart overview the user can update the quantity of a line item, this works fine. But if the product has stock and the updated amount exceeds it, nothing happens and no error is returned. The controller is intended to return an error, but that doesn't seem to work working: // Ensure there's enough stock to fulfill the customer's quantity
if ($product->purchasableType() === ProductType::Product) {
if (is_int($product->stock()) && $request->quantity > $product->stock()) {
return $this->withErrors($request, __("There's not enough stock to fulfil the quantity you selected. Please try again later."));
}
} elseif ($product->purchasableType() === ProductType::Variant) {
$variant = $request->has('variant')
? $product->variant($request->get('variant'))Hey, I’ve been scratching my head on this one for a while. In my cart overview, the user can update the quantity of a line item, and this works fine. However, if the product has stock and the updated amount exceeds it, nothing happens and no error is returned. The controller is intended to return an error, but that’s not working:
: $product->variant($lineItem->variant()['variant']);
if ($variant !== null && is_int($variant->stock()) && $request->quantity > $variant->stock()) {
return $this->withErrors($request, __("There's not enough stock to fulfil the quantity you selected. Please try again later."));
}
} This is from the CartItemController.php:144. So it seems the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I believe you'll need to catch and display the errors on your frontend. I haven't tested this but I think you should be able to use Statamic's If that doesn't work, I'll need to take a deeper look when I have some free time. |
Beta Was this translation helpful? Give feedback.
I believe you'll need to catch and display the errors on your frontend.
I haven't tested this but I think you should be able to use Statamic's
{{ get_errors }}
tag.If that doesn't work, I'll need to take a deeper look when I have some free time.