3 / 4
Aug 2011

We are offering free shipping on 2 units or more. I would like the shoppers to be able to add 2 units of one product into the cart (kind of like here 1http://betulinstore.com/order.php1) Right now I can only a one unit and have the qty changed in the cart.



Is there a way to feed the unit quantity into the Add to Cart function (POST/GET form)

Thanks!

  • created

    Aug '11
  • last reply

    Aug '11
  • 3

    replies

  • 1.2k

    views

  • 2

    users

  • 6

    links

Normally, you would just enable "Let buyer edit quantity" in the product's settings and let them enter their quantity in the cart after they add it. However, if you want your Add to Cart button to pass a predetermined quantity to the cart, you can add &quantity=2 to the button's href= URL, like so:



<a href="https://www.e-junkie.com/ecom/gb.php?c=cart&i=XXXXXX&cl=178295&ejc=2&quantity=2" target="ejejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"><img src="http://www.e-junkie.com/ej/ejadd_to_cart.gif" border="0" alt="Add to Cart"/></a>



If you also want to prevent the buyer from editing that quantity in the cart, you can leave "Let buyer edit quantity" in the product's settings, so whatever quantity the button adds to cart would be the only quantity they can order.



If you need to put a Quantity selection menu in your page next to the Add to Cart button, that's rather more complicated to explain and set up, so just reply to let us know if that's what you actually need.

That worked great! Thank you very much.



Just for others - this is how I did it:

I used an onselect action for the select field with refreshing the page while reading the value of the selected field and adding it into the button URL. Default qty is 1.



<?php

$orderqty = $_REQUEST['qty'];

if ($orderqty == "") $orderqty = 1;



echo '<form name="form" method="POST" action=""><select name="qty" onchange="document.form.submit();">';

for ($i = 1; $i <= 10; $i++) {

echo '<option ';

if ($i == $orderqty)

echo 'selected';

echo '>'.$i.'</option>';

}

echo '</select><a href="https://www.e-junkie.com/ecom/gb.php?c=cart&i=[myID]&cl=[myID]&ejc=2&quantity='.$orderqty.'" target="ejejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"><img src="http://www.e-junkie.com/ej/ejadd_to_cart.gif" border="0" alt="Add to Cart"/></a></form>';

?>

This would also work:



<form action="https://www.e-junkie.com/ecom/gb.php?i=XXXXXX&c=cart&cl=178295&ejc=2" method="POST" target="ejejc">

Quantity:<br>

<select name="quantity">

<option value="2">

<option value="3">

<option value="4">

<option value="5">

<option value="6">

<option value="7">

<option value="8">

<option value="9">

<option value="10">

</select>

<input type="image" src="http://www.e-junkie.com/ej/ejadd_to_cart.gif" onClick="javascript:return EJEJC_lc(this.parentNode);" alt="Add to Cart" class="ec_ejc_thkbx" border="0"/></form>