Developer forum

Forum » Ecommerce - Standard features » Product discount: using variants

Product discount: using variants

Davy Capiau
Reply

Hi,

When implementing a 'X + Y free' product discount, I want to use variants and enable the customer to make a selection between one of them.

Business case: when buying X, get a free t-shirt. The client needs to be able to select the prefered size.

I know it's not possible by default, but isn't there any 'creative' way we could enable something like this? Even if it's less user friendly?


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Not an easy task.

If it is a 'real' discount - i.e. meaning that it is triggered by timeframe or voucher, then you can use orderline fields for the product that gives you the free product. And then combine it with a notification subscriber that will change. So when the Product X is added, it will give Product Y in the master size. Then in the template when rendering the cart, detect the orderline for Product X and detect the orderline for Discount of product Y - then load the variant combinations of Y and display them as anorderline value for Product X and get that stored on product X. When the cart completes, listen to CheckoutDoneOrderIsComplete notification, take the value (variantID) from the orderlinefield of product X and update the orderline of product Y to have this variant id and the product number that goes with it. It has to be done on CheckoutDoneOrderIsComplete - and not before, because the discount is recalculated during checkout. It is not a simple task.

Another option: If everyone can get a free t-shirt and the discount does not have a trigger, you can create a BOM instead - in that way it will be a configurable product and the main product is added to the cart with the t-shirt as part of the configuration. Then set the BOM price to be the price of the main product (X).

BR Nicolai

Votes for this answer: 1
 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hi Nicolai,

I'm trying to understand this scenario a bit better "If it is a 'real' discount - i.e. meaning that it is triggered by timeframe or voucher, then you can use orderline fields for the product that gives you the free product."

As I read it, one of the main complexities is that the order is recalculated during checkout, making the solution more diffcult since you then need to hook in to the process at different points. 

Since I know the free product is not a product that is normally sold in the shop, I guess we could also add the products with price 0 to the catalog, and filter it out of the product list. Then the discount rule can just add the free product, which will show up with price 0, and then the only thing that would need to be customized is the selection of a variant in the cart (ofcourse all variant should then be there with price zero). 

Makes sense or am I overlooking something?

Thanks,

Justin

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Makes sense, and that should be doable.

Votes for this answer: 1

 

You must be logged in to post in the forum