Closed vandres closed 2 years ago
Hi @vandres
That is correct behavior at the moment, right now the cart could be returned to the template in a invalidate state due to a validation error like maxqty when editing it.
You could do this:
{% if cart.hasErrors() %}
{% craft.orders.number(cart.number).one().totalQty %}
{% else %}
{{ cart.totalQty }}
{% endif %}
to get the current DB saved (validated) version of the cart total.
Thank you for the workaround!
What happened?
Description
This is kind of a bug. I am having a product with maxQty. When I add more than that qty, I get an error message stating that. So far so good.
On top of the page, I am displaying a cart icon with the count of products inside the cart.
Now when adding a product with a higher quantity than allowed, the
qty
stills counts up, despite the error.After refreshing the page, it goes back to the real number.
Steps to reproduce
Expected behavior
cart.totalQty
should be 5Actual behavior
cart.totalQty
is 6Craft CMS version
4.2.4
Craft Commerce version
4.1.2
PHP version
8.1
Operating system and version
MacOS, Debian Docker
Database type and version
MariaDB 10.5
Image driver and version
-
Installed plugins and versions