Hi, I have searched the community and found few discussions but couldn't get through the process of what I needed. I am making a module where I will get user data in an html form and on clicking to Add to Cart information will be passed to my cart. The information that I wish to collect in html page is Age (Child/Adult) and Quantity (for both Child and Adult with different rates), whose sum will be automatically calculated in the cart.



I am able to create 2 variants and list them individually but I am not sure if its right. Also, I cant seem to figure out how can i Get quantity of each variant and then calculate them at the cart.

  • created

    Apr '14
  • last reply

    Apr '14
  • 1

    reply

  • 1.2k

    views

  • 2

    users

  • 4

    links

I think what you're getting at is that you want the buyer to enter a quantity for Adult(s) and Child(ren), then click Add to Cart to add both of those to the cart at once?



Unfortunately, we don't really have an easy built-in way to do exactly that, but you could use our multiAdd to Cart function to add Adult and Child items to the cart with a single click, and then the buyer could simply edit the quantity in their cart or remove either one. Looking at the product you have already set up, your multiAdd to Cart button code would look like this:



<a href="javascript:EJEJC_multiAdd(Array(

'https://www.e-junkie.com/ecom/gb.php?c=cart&i=1344009&cl=273512&ejc=2&o1=Adult',

'https://www.e-junkie.com/ecom/gb.php?c=cart&i=1344009&cl=273512&ejc=2&o1=Child'

));"><img src="http://www.e-junkie.com/ej/ejadd_to_cart.gif" alt="Add to Cart" border="0"/></a>



Normally, multiAdd is used to add two different items to the cart at once, but since these are just Variants of the same product, notice we are just taking the URL from the regular Add to Cart button code for that product, duplicating that URL (instead of using different URLs for different items), and adding &o1=Adult or &o1=Child to each URL in order to pass a predefined Variant option1 value for each one.



You should also edit your product's settings to disable "Variations that tell more...", and in its Define Variants screen, change Option1Name to "Ticket" and delete the Option2Name (since you really have only one option with two possible values, Adult or Child).