1

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?

PD24
  • 754
  • 6
  • 16
  • 37
  • What do you really mean? "My issue is that my current code changes the price on the home page also.. so the discount seems to be applying elsewhere.." – Tien Do Jul 13 '11 at 09:46
  • update: i changed it so it affects the varrients in the cart and NOT the whole category.. it works but ONLY if the user is logged in.. The guest checkout does not allow the discount... i need that fixing really. – PD24 Jul 14 '11 at 08:33

0 Answers0