Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to submit multiple products to PayPal, with some having 0 quantity

Tags:

forms

paypal

I'm trying to set up a simple, one-page "buy now" form with multiple product listings and a text input box allowing users to specify how much they would like of each product OR specifying '0' to not add the product to the cart. Of course, if someone just has 0 for a quantity, PayPal returns "You have entered an invalid quantity value. A quantity value must be an integer greater than or equal to one." Is there an easy work-around for getting PayPal to ignore products submitted that have a quantity of "0"? My form essentially it looks like this (fields like total_item_* are for the jquery calculation script):

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="frmCreateCheckboxRange">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="currency_code" value="US">

<fieldset>
<table width="500">

<!-- Product 1 -->
<tr>
<td align="center">
<input type="text" name="quantity_1" id="qty_item_1" value="0" size="2" />
<input type="hidden" name="item_name_1" value="Non-Driver Event Pit Passes (6/ 29 - 7/ 2)" />
<input type="hidden" name="amount_1" value="30.00" />
</td>
<td>Non-Driver Event Pit Passes (6/ 29 - 7/ 2)</a></td>
<td align="center" id="price_item_1">$30.00</td>
<td align="center" id="total_item_1">$0.00</td>
</tr>

<!-- Product 2 -->
<tr>
<td align="center">
<input type="text" name="quantity_2" id="qty_item_2" value="0" size="2" />
<input type="hidden" name="item_name_2" value="Non-Driver Single Day Pit Passes (Fri. 6/29)" />
<input type="hidden" name="amount_2" value="15.00" />
</td>
<td>Non-Driver Single Day Pit Passes (Fri. 6/29)</td>
<td align="center" id="price_item_2">$15.00</td>
<td align="center" id="total_item_2">$0.00</td>
</tr>
</table>

<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit">
</fieldset>
</form>
like image 574
Jonathan Avatar asked Nov 15 '22 05:11

Jonathan


1 Answers

Your best bet is to include a Remove from Cart button for each item.

like image 101
Robert Harvey Avatar answered Dec 31 '22 06:12

Robert Harvey