Forum
Notifying User That Maximum Cart Qty Has Been Reached
Would the best way to notify the user that max_in_cart
has been reached be to loop over each cart item, and then call perch_shop_products
on each product and test against the value of the max_in_cart
ID? Then display a message if true.
Actually that's not going to work is it. The cart qty will never exceed
max_in_cart
so the test will always fail.I think you use
max_in_cart
when the customer is trying to add a product to the cart - either warn they have selected too many for that product or only allow them to select up to that amount.Yes that's right but you don't just want to limit it on the cart page and not notify that user what has happened and/or why. ie "You have reached the maximum allowed in the cart for product x"
Would the product description not include "maximum number per order" in the text?
Perhaps, but:
I think it's a bad user experience to place limitations on something but not providing the user with any feedback.
In that case you could possibly pass something to the cart using a
cart_property
- and use that value to display some text in the cart.Yeah that is an option but the issue is testing if
max_in_cart
has been exceeded.When buying the product, if
quantity
=max_in_cart
, usecart_property
to pass some text to the cart. I'm still not sure how the customer is able to exceedmax_in_cart
.Technically they can exceed it, Perch then handles reducing the number of items in the cart back down to the maximum allowed. A better way of wording it would be to test if a user has attempted to exceed
max_in_cart
.This wouldn't work because I need to test if the quantity exceeds
max_in_cart
, but Perch performs the logic and takes the necessary actions on the cart before I can run my test.I guess an alternative would be to create our own
max_in_cart
field and then test against that before the cart is loaded. Then reduce the number of items in the cart programmatically if it's been exceeded. But this seems a bit like reinventing the wheel to just show the user a message.For a bit of context:
A user has added a product to the basket of qty 1. They then go to the cart page and change the qty to 6 but that product has max_cart_qty of 5. So when they then update the cart, Perch reduces it back down to 5 but there is no indication to the user why that's just happened.
For each
cartitem
in the cart,max_in_cart
is passed in (you won't need a cart_property) - edit the<perch:input
for theQty
column to includeThen the customer won't be able to add more to the cart than is allowed?
Yep that's not a bad idea but there's still no indication to the user as to why.
I'm thinking unless Drew can offer a solution then I may take this route and also dynamically display a note on the cart (and product) page next to the qty field about the maximum allowed, using
<perch:cartitem id="max_in_cart" />
.Appreciate the effort Duncan.
If you use
max="<perch:cartitem id="max_in_cart" />"
like Duncan suggested, you can use Javascript to display a note when appropriate. Proof of concept