I'm developing a shop based on Drupal Commerce which sells customizable objects. I'd like to be able to order t-shirts of a certain type in different colors an sizes (like 5 orange ones size XS, 10 blue ones size L...).

This would normally be done by going to the product page, selecting "orange" as the color, "XS" as the size, adding it to the cart, then going back to the product page...but this is too complicated.

So I'm wondering what is the cleanest approach to achieve this.

Here is an example of the result I would like to obtain (choose a color, then a size, then a quantity, do it as many times as you need, then only click add to cart) : http://www.objetrama.fr/tee-shirt-personnalise-femme-melrose-150-gr-m.html

I think this could be done by finding a way to send multiple add to cart requests from the same page using ajax (tried this approach with not much success). Another solution would be to create a custom add to cart function which accepts multiple products with different attribute values.

1 Answer 1


Since your not sending a single SKU, you could just overwrite the validate and submit handler for the add to cart form and then, using the existing validate and submit handlers as a blueprint, write your own logic to add multiple products. You'll want to make sure you create line-items for each of the variants your adding to the cart so that pricing is calculated properly, but it should be a fairly straightforward process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.