Tier Prices across Variants

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
Is there any way to setup the tier prices across product variants?   I have a product that the variants are flavors and I give a discount if the customer orders more then 6 to make a complete case,    So if they order 3 of one variant then 3 of another I want the discount to apply to all variants

Thoughts?

Thanks
-Keith
14 年 前
I ended up changing GetTierPrice and added a check to loop through all the similar variants in the cart and re calculate the qty before nop changes the price.  Works great still needs a bit more testing with multiple tier prices etc and some error checking in case the tier price settings arent the same for all the variants.

I set all the variants in the product to the same qty and price in tier prices.  this gets calculate correctly when adding to the cart or changing the qty's of the items in the cart

protected static decimal GetTierPrice(ProductVariant productVariant, int Quantity)
        {
            var tierPrices = productVariant.TierPrices;
            // TierPrice Across all variants
            var newQuantity = 0;

            var Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);

            foreach (var theCartItem in Cart)
            {
                if (productVariant.ProductID == theCartItem.ProductVariant.ProductID)
                {
                    newQuantity += theCartItem.Quantity;
                }
            }

            if (newQuantity != 0) {Quantity = newQuantity;}
            // TierPrice Across all variants

            int previousQty = 1;
            decimal previousPrice = productVariant.Price;            
            foreach (TierPrice tierPrice in tierPrices)
            {
                if (Quantity < tierPrice.Quantity)
                    continue;

                if (tierPrice.Quantity < previousQty)
                    continue;

                previousPrice = tierPrice.Price;
                previousQty = tierPrice.Quantity;
            }

            return  previousPrice;
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.