nopCommerce折扣问题?
我正在使用 noCommerce 1.9 并将代码的“HasOneOfTheseProductVarientsInTheCart”部分修改为:
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;
它运行良好,因为我在系统中定义了产品变体 id,并且它仅将折扣应用于该产品。
我希望能够以 20 英镑购买 2 件商品,并以全价购买 1 件单品(11.99 英镑)。
所以基本上每个奇数都是全价。
我的问题是我当前的代码也更改了主页上的价格..所以折扣似乎适用于其他地方..
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论