Hi Michal,
I have added those lines to my code but I think I am not sure under which class am I suppose to add it.
Below is the error message that I am getting afteer adding those lines:
CS1061: 'CustomShoppingCartInfoProvider' does not contain a definition for 'ShoppingCartInfoObj' and no extension method 'ShoppingCartInfoObj' accepting a first argument of type 'CustomShoppingCartInfoProvider' could be found (are you missing a using directive or an assembly reference?)
Error Line: if (this.ShoppingCartInfoObj.ShoppingCartDiscountCouponID > 0)
Below is my complete code for CustomShoppingCartInfoProvider.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.Ecommerce;
using CMS.GlobalHelper;
using CMS.EcommerceProvider;
public class CustomShoppingCartInfoProvider : ShoppingCartInfoProvider
{
protected override double CalculateOrderDiscountInternal(ShoppingCartInfo cart)
{
double result = base.CalculateOrderDiscountInternal(cart);
double UnitPrice = 24.90;
double CartAmount = cart.TotalItemsPriceInMainCurrency;
double CartQuantity = CartAmount/UnitPrice;
double DiscountAmount =0;//Discount should be declared in if Condition
double NewPricePerUnit = 0;//UnitPrice - DiscountAmount
double NewCartAmountAfterDiscount = 0;//CartQuantity * NewPricePerUnit
if (this.ShoppingCartInfoObj.ShoppingCartDiscountCouponID > 0)
{
DiscountCouponInfo dci = DiscountCouponInfoProvider.GetDiscountCouponInfo(ShoppingCartInfoObj.ShoppingCartDiscountCouponID);
}
if(CMS.CMSHelper.CMSContext.CurrentSiteName == "EcommerceSite")
{
if (CartQuantity == 1)
{
}
else if (CartQuantity == 2)
{
DiscountAmount = 1;
NewPricePerUnit = UnitPrice - DiscountAmount;
NewCartAmountAfterDiscount = CartQuantity * NewPricePerUnit;
result = CartAmount - NewCartAmountAfterDiscount;
}
else if (CartQuantity == 4)
{
DiscountAmount = 3;
NewPricePerUnit = UnitPrice - DiscountAmount;
NewCartAmountAfterDiscount = CartQuantity * NewPricePerUnit;
result = CartAmount - NewCartAmountAfterDiscount;
}
else if ((CartQuantity >= 5) && (CartQuantity < 10))
{
DiscountAmount = 4;
NewPricePerUnit = UnitPrice - DiscountAmount;
NewCartAmountAfterDiscount = CartQuantity * NewPricePerUnit;
result = CartAmount - NewCartAmountAfterDiscount;
}
else if (CartQuantity >= 10)
{
DiscountAmount = 5.40;
NewPricePerUnit = UnitPrice - DiscountAmount;
NewCartAmountAfterDiscount = CartQuantity * NewPricePerUnit;
result = CartAmount - NewCartAmountAfterDiscount;
}
else
{
result = 6;
}
}
return result;
}
}
Am I missing a assembly?
Your help is much appreciated.
Thanks
Gitesh Shah