Quantcast
Channel: Kentico CMS for ASP.NET - DevNet - Forums - Version 7.x - API
Viewing all articles
Browse latest Browse all 660

RE:Discounts on the fly?

$
0
0
sh_dev
Hi David. Thank you for your concise reply. This is the approach I was taking earlier but for some reason the ShoppingCartInfo object fails to
A: reflect the discount in the product totals
B: maintain that state through the shopping cart wizard.
ShoppingCartInfoProvider.EmptyShoppingCart(ShoppingCart);

ShoppingCartItemInfo addedItem = ShoppingCart.SetShoppingCartItem(cartItemParams);

var total = ShoppingCart.TotalPrice; //57.00 at this time.
var discount = new ItemDiscount()
{
ItemDiscountID = Guid.NewGuid().ToString().Substring(0, 4),
ItemDiscountDisplayName = "discount" + addedItem.SKU.SKUName,
ItemDiscountValue = 10,
ItemDiscountedUnits = addedItem.CartItemUnits,
ItemDiscountIsFlat = false,
ItemDiscountIsGlobal = false
};


addedItem.ProductDiscounts.Add(discount); //note that this does NOT create a discount DataRow.

//Save the data to dataase
ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(addedItem);

//the docs say this should apply/update all the items in the shopping cart.
ShoppingCartInfoProvider.EvaluateShoppingCart(ShoppingCart);

total = ShoppingCart.TotalPrice; //57.00 !!! its Still 57.00

I am sorry but I am just not seeing how the shopping cart applies these discounts or the method to call for it to do so.

sincerely
Mac

Viewing all articles
Browse latest Browse all 660

Trending Articles