Bundle with products sorted inside categories

Hi !

I have a specific use case for a customer and I don’t know if Commerce support this feature.
My customer is a food truck and it’s selling classical products with also bundled menu : a set of products sorted on 3 categories : main dish + drink + dessert
The final price, for this bundled menu, depend of the selected main dish.
Here a mockup of the front-end for visitor (right side) :

Can you please confirm me that kind of use case can be implemented with current version of Commerce ?

Thanks :slight_smile:

There’s no out-of-the-box solution in Commerce right now that lets you essentially configure a configurator like that. There are bundle products, but the contents of those are configured by the shop owner; not the customer.

If you only had 2 “variables”, you could use a product matrix which automatically creates a product for each unique combination, but it looks like you need more variables than that.

What you would probably need to do is add a product list tv for each “step” (“Bo bun”, “Nems”, “Boissons”, “Desserts”), that will allow the shop owner to add those products and the price for each. (If you wanted, you could also fetch the products from a central “Drinks” resource if those options are the same for all menus.)

Then you need a custom add-to-cart snippet that takes in a POST request with the selected product IDs, calculates the final price/bundled menu name/etc, and adds it to the cart programmatically. That post has some more details about the different ways you could do that. I’d probably recommend option 2 where you base the order item off your main dish, and then adjust the name/pricing/additional details to match the rest of the selection.

If only the main dish affects the price, another approach which requires no code would involve the ItemData module. The product that would be added to the cart is the main dish, and the other selections would be added as basically key => value pairs of information. Simple to implement, but with some restrictions on what it can do unlike the more custom approach.

Thanks for your kick answer (very appreciable !!!)
I think your last suggestion will do the job, because only the main dish affect the final price of the bundle.
I will dig on this way :slight_smile:

Now it’s time to implement this :slight_smile:

I have an issue to get item data on the items.twig template from a select list on the product page.
The MODX generated code for the add to cart form is the following :

<form method="post" class="product-list-addform add-to-cart" action="cart">
  <input type="hidden" name="add_to_cart" value="1" />
  <input type="hidden" name="product" value="42" />
  <input type="hidden" name="quantity" value="1" />
  <input type="hidden" name="link" value="53" />
  <label for="choice">Choice : </label>
  <select id="choice" name="choice">
    <option value="Choice 1">Choice 1</option>
    <option value="Choice 2">Choice 2</option>
    <option value="Choice 3">Choice 3</option>
  <input class="cta-button" type="submit" value="Add to cart" />

On the items.twig I have :

<small>{{ lex('commerce.cart.product_code') }}: {{ item.sku|e }}
   {% if item.description %} | {{ item.description|e }} {% endif %}
   Choice: {{ item.properties.choice }}

After adding the product, I have on the cart the word “Choice:” but not the item data.

What’s wrong ?

Did you enable the ItemData module and add choice to it’s allowed fields?

I had enable ItemDAta Module but I didn"t understood that I had to add my field to the allowed fields inside the module !
It’s done now, and - obviously - it’s working now :slight_smile:
Thanks :slight_smile:

1 Like