Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Does "Min items in one order" work as expected? View modes: 
User avatar
Member
Member
matt-awg - 5/2/2013 12:12:30 PM
   
Does "Min items in one order" work as expected?
The "Min items in one order" field on a product does not seem to work right for me.

According to the documentation:
Min items in one order - defines the minimum number of items in one order.

Here is what happens. I set this to 5 for an item. I figured out how to make the quantity box on the product page default to the minimum qty value. And even if the user tries to enter a different quantity in this box, it does work and it increases it to 5. BUT if the user then from their cart edits the quantity and updates the quantity to 2, it allows them to do update it to less than the min. Why is that? If I try to place the order, it does fail w/ error message about min qty, but shouldn't it never allow them to enter an invalid value?

Is that the intended behavior(I guess technically it says Min in one order, not in one cart)? And if that is the desired behavior and not a bug, is this something I can override without a source code license? A custom info provider maybe?

Thanks,
Matt

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/8/2013 7:54:09 PM
   
RE:Does "Min items in one order" work as expected?
Hello Matt,

As I wrote in the ticket (we can optionally continue there and then add the conclusions here for anyone interested), the check for validity of the cart content (and met conditions) is done by ShoppingCartInfoProvider.CheckShoppingCart method and the result is then displayed in the error message (if there's any error).
This code is in the ProcessStep and OnPreRender (I forgot about that one in the ticket, sorry) methods in
~\CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartContent.ascx.cs
step control code, so you could modify it and add some automatic removal of the item that failed the check, or change the quantity to meet the condition. The first method is run when you proceed to checkout, the second one is run when the shopping cart is being prepared for rendering.

The checked items with the check results are in the ItemResults property of the ShoppingCartCheckResult checkResult,
Individual items - objects of type ShoppingCartItemCheckResult have the MaxUnitsExceeded or MinUnitsNotReached property, which is true in case of the unit count limit conditions are not met.

Either way, the control won't allow you to continue. If you have the problem with this behavior, you can change that as I'm writing above.

This is currently the default behavior. The advantage for the customer is that he sees what's the limit. If there was any automatic update of the value, the customer might be confused what's happening, if you didn't inform him about that limit.

Furthermore, you could customize the ShoppingCartItemSelector control so that it would limit the units input textbox to the specified interval for the product. This is what you have probably made ("I figured out how to...").
The only problem with this solution is that it may need to perform additional queries for data, thus creating more load (on server resources).

Please feel free to contact us if you have any additional questions.

Regards,
Zdenek

User avatar
Member
Member
matt-awg - 5/13/2013 9:54:58 AM
   
RE:Does "Min items in one order" work as expected?
Part of the problem is I am using a highly customized single page checkout form. What I ended up doing to make this work was to just override these methods in the ShoppingCartInfoProvider:
protected override void UpdateShoppingCartItemInternal(ShoppingCartItemInfo item, ShoppingCartItemParameters itemParams)

protected override ShoppingCartItemInfo AddShoppingCartItemInternal(ShoppingCartInfo cart, ShoppingCartItemParameters itemParams)

Inside these methods I force the quantity to meet the minimum requirement. This does not alert the user, but it seems to work for my client, well at least they have not complained about it yet! The items are clearly marked with a min qty so the user should not be surprised.

I also set the default quantity on the ShoppingCartItemSelector control to have the min qty, so again, the user should understand they must purchase this amount.

Thanks for your help!

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/25/2013 11:34:17 PM
   
RE:Does "Min items in one order" work as expected?
Hi Matt,

Thanks for posting your solution here.
The ultimate word should always be from the users - customers, who actually go through the checkout, so as long as they're fine with this, and there is some information or hint about what's needed quantity etc., this automated way is quite good approach.

Please feel free to contact us if you have any additional questions.

Regards,
Zdenek

User avatar
Member
Member
matt-awg - 6/27/2013 7:50:43 AM
   
RE:Does "Min items in one order" work as expected?
Hi Zdenek,
Sorry for the delayed reply but just for anyone that ever is looking into doing something similar, the client ended up complaining about the lack of explanation to the shopper as to what was happening so I did add some custom JavaScript that prevents the user from ever entering an invalid quantity and alerts them to the requirements. I output hidden fields in the cart that have the quantity requirements for each item and then use those hidden fields to check each quantity entered for each item to make sure it meets requirements and if not, alert the user and cancel the form submission. I still left all the server side validation as well just to make sure quantities are always correct in case someone bypasses the JavaScript validation somehow.
Thanks,
Matt

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 7/1/2013 5:47:28 AM
   
RE:Does "Min items in one order" work as expected?
Hi,

No worries. Your described solution seems to be really robust and user-friendly.

Please let me know if I can be of any further assistance.

Kind regards,
Zdenek