nopCommerce discount issue?
I am using noCommerce 1.9 and have modified the "HasOneOfTheseProductVarientsInTheCart" part of the code to this:
case 开发者_开发问答DiscountRequirementEnum.HasOneOfTheseProductVariantsInTheCart:
{
if (customer != null)
{
CustomerSession customerSession = IoC.Resolve<ICustomerService>().GetCustomerSessionByCustomerId(customer.CustomerId);
if (customerSession != null)
{
var restrictedProductVariants = IoC.Resolve<IProductService>().GetProductVariantsRestrictedByDiscountId(discount.DiscountId);
var cart = IoC.Resolve<IShoppingCartService>().GetShoppingCartByCustomerSessionGuid(ShoppingCartTypeEnum.ShoppingCart, customerSession.CustomerSessionGuid);
bool found = false;
int totalfound = 0;
foreach (ProductVariant restrictedPv in restrictedProductVariants)
{
foreach (ShoppingCartItem sci in cart)
{
if (restrictedPv.ProductVariantId == sci.ProductVariantId)
{
// found = true;
totalfound++;
if (sci.Quantity > 1)
{
totalfound++;
}
break;
}
}
/*if (found)
{
break;
}*/
}
if (totalfound>1)
return true;
}
}
}
break;
It works well, as i define the product varient ids in the system and it applies the discount to that only.
I want to be able to have 2 items for £20 AND 1 single item for full price, (£11.99p).
So basically every odd number is full price.
My issue is that my current code changes the price on the home page also.. so the discount seems to be applying elsewhere..
any ideas?
精彩评论