Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Couple of ECommerce questions (Limiting quantity of product per customer) View modes: 
User avatar
Certified Developer v6
Certified Developer v6
Dave - 2/6/2014 10:13:08 AM
   
Couple of ECommerce questions (Limiting quantity of product per customer)
Hi,

Is it possible to limit the number of a particular product per customer? Eg: Maximum 3 widgets per customer/order.

Also, is it possible to have the first 3 quantity of a particular product be free for a customer, while any quantity over 3 would cost? Eg: Order 3 widgets, $0; order 4 widgets, $10; order 5 widgets, $20; etc.

I do see there are some improved discounting rules coming in v8 - but is anything like this available in v7?

Thanks!
Dave

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 2/14/2014 8:23:55 AM
   
RE:Couple of ECommerce questions (Limiting quantity of product per customer)
Hi Dave,

You can limit maximum number units of each item its properties, however this setting is only per-item and cannot be set for a group of items. It also does not limit user from submitting multiple orders matching the item limit, you would need to add such validation directly in the shopping cart methods.

Regarding your second question, Kentico does not offer discounts of this type out of the box, but you can create virtually any item discount you need by overriding this provider method and inserting your custom discount on fly:

public class CustomShoppingCartItemInfoProvider : ShoppingCartItemInfoProvider
{
/// <summary>
/// Returns the list of all discounts which should be applied to the specified shopping cart item.
/// </summary>
/// <param name="item">Shopping cart item</param>
protected override List<IItemDiscount> GetDiscountsInternal(ShoppingCartItemInfo item)
{
List<IItemDiscount> discounts = base.GetDiscountsInternal(item);

if (discounts != null && item != null)
{
DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo(item.SKU.SKUDepartmentID);

if (department != null)
{
if (department.DepartmentDisplayName == "Free Samples")
{
// Add aaMyDiscount
ItemDiscount aaMyDiscount = new ItemDiscount
{
ItemDiscountType = DiscountTypeEnum.CustomDiscount,
ItemDiscountValue = 100,
ItemDiscountIsFlat = false,
ItemDiscountedUnits = 3,
ItemDiscountCustomData = null,
ItemDiscountDisplayName = "Free Samples Limit",
ItemDiscountIsGlobal = false,
ItemDiscountID = "ThreeSamplesLimit"
};

discounts.Add(aaMyDiscount);
}
}
}

return discounts;
}
}


This example is somewhat similar to what you ask for, making first three units of any item in department "Free Samples" free. Any first three smartphones in order will be free. Modifying the condition to check for specific SKUID(s) should achieve just what you describe.

Regards,
Josef Dvorak