Adding group of products to the shopping cart with discount and with one click

I have a question for those who are already a bit more familiar with Treepl’s eCommerce system. Our client sells courses on his website. Some courses can be purchased as a set of 2 or 3 for a reduced price. There is a button in place to buy the whole set in one go for the reduced price. But users can also pick the courses in the set individually to get the reduced price on checkout.
My idea is to group the courses to create the sets, then check on checkout if all courses in the group are in the shopping cart, then add a special discount code in the discount code field which is hidden from the frontend.
Are there any other approaches to apply discounts on a group of items I have missed?
Is there any way to implement a “purchase” button which adds all products in a group to the shopping cart?

If in the ‘set’ view you can list all the products (either hidden or shown) and include the ‘add to cart’ buttons (and the required {{this.ProductDataJsonHTML}}), then you can trigger all those button clicks at once, eg:

$('[data-ecommerce_add_to_cart_item]').trigger('click');

This works in a test I did.

There is probably a nicer way to do this by calling the add to cart function in the eCommerce JS, but I’m not sure how to pass all the product data to it.


A possible alternative setup could be to have a shell product, which is the set/group and create a checkbox attribute group (required) with each of the actual courses as options.
These could be added to the inventory if you need to track them and have their own codes, etc.
The user could then select all the courses or just a selection and add the shell product to the cart.
Should be pretty easy to then check if all attributes added or not.

That’s super valuable input, @Adam.Wilson. Thanks! I hoped for a JS solution, not knowing if the system will digest that. Knowing that this would work, saves us a lot of time.

We have something similar in a BC site that we did years ago - have worked fine :+1:

1 Like