Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting cart to paypal?

Status
Not open for further replies.

tshey

Technical User
Dec 28, 2005
78
AU
Hi all, I need to pass the data that has been selected in my cart to paypal through hidden form fields. The requirement from paypal are that each item must increment like input type="hidden" name="item_name1" value="item1"
I have my cart
Code:
<form name="frmCart" method="get">
		
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr class="green">
				<td width="15%" height="25">
						&nbsp;&nbsp;Qty
				</td>
				<td width="55%" height="25">
						Product
				</td>
				<td width="15%" height="25" >
						Price Each
				</td>
				<td width="15%" height="25" >
					&nbsp;Remove Item </td>
			</tr>
			<?php
			while($row = mysql_fetch_array($result))
			{
				// Increment the total cost of all items
				$totalCost += ($row["qty"] * $row["itemPrice"]);
				?>
					<tr>
						<td width="15%" height="25">
								<select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)">
								<?php
								
									for($i = 1; $i <= 20; $i++)
									{
										echo "<option ";
										if($row["qty"] == $i)
										{
											echo " SELECTED ";
										}
										echo ">" . $i . "</option>";
									}
								?>
								</select>
						</td>
						<td width="55%" height="25">
								<?php echo $row["item_name"]; ?>
						</td>
						<td width="20%" height="25">
								$<?php echo number_format($row["itemPrice"], 2, ".", ","); ?>
						</td>
						<td width="10%" height="25">
								<a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Remove</a>
							
						</td>
					</tr>
				<?php
			}
			
			// Display the total
			?>
					<tr>
						<td width="100%" colspan="4">
							<hr />
						</td>
					</tr>
					<tr>
						<td width="70%" colspan="2">
						</td>
						<td width="30%" colspan="2">
								<b>Total: $<?php echo number_format($totalCost, 2, ".", ","); ?></b>
						</td>
					</tr>
		  </table>
		
		</form>
and my paypal form code
Code:
<form action="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr"[/URL] method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="info@test.com.au">
<input type="hidden" variable name="item_name_1" value="<?php echo $row["item_name"]; ?>1">
<input type="hidden" name="amount_1" value="<?php echo number_format($row["itemPrice"], 2, ".", ","); ?>">
<input type="hidden" name="currency_code" value="AUD">

<input type="image" src="[URL unfurl="true"]https://www.paypal.com/en_US/i/btn/x-click-but23.gif"[/URL] border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="[URL unfurl="true"]https://www.paypal.com/en_AU/i/scr/pixel.gif"[/URL] width="1" height="1">

</form>
How do I set this up so it is holding my first form values and increment to paypal specifications?
 
It will not hold what is in the cart in the hidden fields, what am I doing wrong I must be missing something?
 
I have added it to the first form and it passes one variable at a time. Is this the best way to submit it as my first form is get and paypal is suppose to be post? how do I make it select the second item and send it through as item_name_2?
 
Code:
<form name="frmCart" method="get"  action="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr">[/URL]
		<input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="business" value="chris.n@vacuumshop.com.au">
		
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr class="green">
				<td width="15%" height="25">
						&nbsp;&nbsp;Qty
				</td>
				<td width="55%" height="25">
						Product
				</td>
				<td width="15%" height="25" >
						Price Each
				</td>
				<td width="15%" height="25" >
					&nbsp;Remove Item </td>
			</tr>
			<?php
			while($row = mysql_fetch_array($result))
			{
				// Increment the total cost of all items
				$totalCost += ($row["qty"] * $row["itemPrice"]);
				?>
					<tr>
						<td width="15%" height="25">
								<select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)">
								<?php
								
									for($i = 1; $i <= 20; $i++)
									{
										echo "<option ";
										if($row["qty"] == $i)
										{
											echo " SELECTED ";
										}
										echo ">" . $i . "</option>";
									}
								?>
								</select>
								<input type="hidden" name="quantity_1" value="<?php echo $row["qty"];?>">
						</td>
						<td width="55%" height="25">
								<?php echo $row["item_name"]; ?>
								<input type="hidden" name="item_name_1" value="<?php echo $row["item_name"]; ?>">
								
						</td>
						<td width="20%" height="25">
								$<?php echo number_format($row["itemPrice"], 2, ".", ","); ?>
								<input type="hidden" name="amount_1" value="<?php echo number_format($row["itemPrice"], 2, ".", ","); ?>">
						</td>
						<td width="10%" height="25">
								<a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Remove</a>
							
						</td>
					</tr>
				<?php
			}
			
			// Display the total
			?>
					<tr>
						<td width="100%" colspan="4">
							<hr />
						</td>
					</tr>
					<tr>
						<td width="70%" colspan="2">
						</td>
						<td width="30%" colspan="2">
								<b>Total: $<?php echo number_format($totalCost, 2, ".", ","); ?></b>
						</td>
					</tr>
		  </table>
		
		
		<table width="100%"  border="0" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>




<input type="hidden" name="currency_code" value="AUD">

<input type="image" src="[URL unfurl="true"]https://www.paypal.com/en_US/i/btn/x-click-but23.gif"[/URL] border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="[URL unfurl="true"]https://www.paypal.com/en_AU/i/scr/pixel.gif"[/URL] width="1" height="1">
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top