Developer forum

Forum » Ecommerce - Standard features » Order discount for products in a specific product group

Order discount for products in a specific product group

Jens Jakob Kristensen
Jens Jakob Kristensen
Reply

Hi,

We are trying to figure out a soultion to offer a specific order discount scenario.

The shop has products for different brands sorted in different product groups (group names: Brand A, Brand B etc.).

The order Discount (inclusive) we want to offer is based on a voucher: -300 DKK on your order, but only for Brand A products. Not an order consisting of prodicts from different brands.

In the definition of the Order Discount we have added the product group "Brand A" in the field "Products and/or groups". And we have added the other product brand groups (Brand B, Brand C etc.) in the field "Excluded products and/or groups". Hoping that the other brands would negate the discount, if products from these groups were also added to the cart. But no.

Currently the discount applies for the order when ever there is a Brand A product in the cart. It doesn't matter if there are products from other brands in the cart (the excluded ones).

Is there any way of configuring the discount so that the discount will apply ONLY if the cart consists solely of Brand A products. Any combination of products from more than Brand A should negate the discount.

Thank you in advance.


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jens Jakob

No, that is not possible.

The exlude is meant for the scenario, "If you buy a product from brand a, except product y, you get the discount".

So the only option right now is to add additional logic - either in some code that will remove the discount again, or in the cart where you will disallow the voucher if the cart contains the 'wrong' brands - you can do that using some javascript that will remove the voucher code and re-submit the order.

We have just completed development of a DiscountExtender feature - that is a new extensibility point for the Discounts & Offers.

Then you can create code like this:

public class DiscountFilterCheapProducts : DiscountExtenderBase
    {

//Additional product discount logic

        [AddInParameter("Cheap price"), AddInParameterEditor(typeof(IntegerNumberParameterEditor), "minValue=0;maxValue=1000;allowNegativeValues=false;localizeValues=true;")]
        public int CheapPrice { get; set; }

        public DiscountFilterCheapProducts()
        {
            CheapPrice = 100;
        }

        public override bool DiscountValidForProduct(Product product)
        {
            return product.Price.Price <= CheapPrice;
        }

//Additional order discount logic

        [AddInParameter("Favorite name"), AddInParameterEditor(typeof(TextParameterEditor), "")]
        public string FavoriteName { get; set; }

        public DiscountFilterForMarta()
        {
            FavoriteName = "Marta";
        }

        public override bool DiscountValidForOrder(Order order)
        {
            var valid = false;

            if (!string.IsNullOrEmpty(FavoriteName) && !string.IsNullOrEmpty(order.CustomerName))
            {
                valid = order.CustomerName.StartsWith(FavoriteName, System.StringComparison.OrdinalIgnoreCase);
            }
           
            return valid;
        }

    }

But that is not ready for release yet...

BR Nicolai

Votes for this answer: 1
 
Jens Jakob Kristensen
Jens Jakob Kristensen
Reply

Hi Nicolai,

Thank you for your input. It makes sense for now.

I guess the optimal solution would be to await the release of the DiscountExtender, but I think we will in to the other options you suggested.

 

You must be logged in to post in the forum