Tags/topics: 
1
Answers
Vote up!
1
Vote down!

Add to cart form with ability to buy two same products with line item fields

Hi!

I'm looking for a solution to make add to cart form for contact lenses. For choosing vision defect parameters I use line item fields. The problem is that user needs ability to buy second product if he got different defect on other eye in same add to cart form.
http://screenshooter.net/100249231/clhwond

When user choose different defect for second eye something like that needs to show up:
http://screenshooter.net/100249231/evhrmjl

I'm looking for solution to make such add to cart form.

I have two ideas:

  • Making two add to cart forms per display page. First normal and second with two same products (as showed on second screenshot). Using radio button I can switch between forms.
  • Having only one add to cart form but using radio button to show additional line item for same product.

I don't know how I can handle that ideas. I thought that I can somehow use or hack "Commerce Add to Cart Extras" but it doesn't allow to show line item fields. Any tips or some code samples how to make custom (similar?) add to cart form would be useful.

Lukasz Zmudziak
Asked by: Lukasz Zmudziak
on October 31, 2014

1 Answer

Vote up!
0
Vote down!

Hey Lukasz, in this case I'm not sure there's a simple answer any way you look at it. Honestly, my recommendation would be to evaluate adding line item field support to "Commerce Add to Cart Extras". Your only other option would be some sort of custom Add to Cart form that facilitated dual form submission, maybe through some Ajax. I'm not sure that's less work than altering the existing extras module, though.

If you do go that direction, I'd love for you to share the result in a patch to the module. : )

Ryan Szrama
Answer by: Ryan Szrama
Posted: Nov 14, 2014