如何从购物车中获取多个产品到贝宝付款
how to get multiple products from cart to paypal payment
我想在paypal支付页面获取多个产品。我现在只得到一个单一的第一个产品。有人可以帮我解决我错的地方吗?下面是我的代码..我搜索了 google 并发现了另外两处需要更改的地方。即 _xclick 到 _cart 和一个 <input type='hidden' value='1' name='upload'/>
现在我知道你的购物车是空的。
$query = mysql_query("SELECT * FROM temporderdetails WHERE omid = '$ordermaster_id' " ) or die(mysql_error());
while($row = mysql_fetch_array($query)){
$productid = $row['productid'];
$quantity = $row['qty'];
$price = $row['price'];
$subtotal = $row['subtotal'];
$query1 = mysql_query("select product_name from products where product_id = '$productid'" ) or die(mysql_error());
while($row1 = mysql_fetch_array($query1)){
$product = $row1['product_name'];
<form action='<?php echo $payment_url ;?>' method='post'>
<input type="hidden" name="cmd" value="_cart">
<input type='hidden' name='business' value='<?php echo $payment_email;?>'>
<input type='hidden' name='item_name' value='<?php echo $product;?>'>
<input type='hidden' name='upload' value='1'>
<input type='hidden' name='quantity' value='<?php echo $quantity; ?>'>
<input type='hidden' name='amount' value='<?php echo $grandtotal;?>'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='return' value='<?php echo $payment_success;?>'>
<input type='hidden' name='cancel_return' value='<?php echo $payment_failed;?>'>
}
}
如果有多个产品,您必须为每个产品使用以下变量:
amount_x
item_name_x
其中x为产品编号(从1开始)。所以,你要做的是这样的:
<form action='<?php echo $payment_url ;?>' method='post'>
<input type="hidden" name="cmd" value="_cart">
<input type='hidden' name='business' value='<?php echo $payment_email;?>'>
<input type='hidden' name='upload' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='return' value='<?php echo $payment_success;?>'>
<input type='hidden' name='cancel_return' value='<?php echo $payment_failed;?>'>
在这里你可以得到你所有的产品(你的"while"语句),使用一个计数器变量,然后:
<input type='hidden' name='amount_<?php echo $counter;?>' value='<?php $price ?>'>
<input type='hidden' name='item_name_<?php echo $counter;?>' value='<?php echo $product?>'>
<?php $counter++ ?>
最后关闭表单
</form>
我想在paypal支付页面获取多个产品。我现在只得到一个单一的第一个产品。有人可以帮我解决我错的地方吗?下面是我的代码..我搜索了 google 并发现了另外两处需要更改的地方。即 _xclick 到 _cart 和一个 <input type='hidden' value='1' name='upload'/>
现在我知道你的购物车是空的。
$query = mysql_query("SELECT * FROM temporderdetails WHERE omid = '$ordermaster_id' " ) or die(mysql_error());
while($row = mysql_fetch_array($query)){
$productid = $row['productid'];
$quantity = $row['qty'];
$price = $row['price'];
$subtotal = $row['subtotal'];
$query1 = mysql_query("select product_name from products where product_id = '$productid'" ) or die(mysql_error());
while($row1 = mysql_fetch_array($query1)){
$product = $row1['product_name'];
<form action='<?php echo $payment_url ;?>' method='post'>
<input type="hidden" name="cmd" value="_cart">
<input type='hidden' name='business' value='<?php echo $payment_email;?>'>
<input type='hidden' name='item_name' value='<?php echo $product;?>'>
<input type='hidden' name='upload' value='1'>
<input type='hidden' name='quantity' value='<?php echo $quantity; ?>'>
<input type='hidden' name='amount' value='<?php echo $grandtotal;?>'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='return' value='<?php echo $payment_success;?>'>
<input type='hidden' name='cancel_return' value='<?php echo $payment_failed;?>'>
}
}
如果有多个产品,您必须为每个产品使用以下变量: amount_x item_name_x
其中x为产品编号(从1开始)。所以,你要做的是这样的:
<form action='<?php echo $payment_url ;?>' method='post'>
<input type="hidden" name="cmd" value="_cart">
<input type='hidden' name='business' value='<?php echo $payment_email;?>'>
<input type='hidden' name='upload' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='return' value='<?php echo $payment_success;?>'>
<input type='hidden' name='cancel_return' value='<?php echo $payment_failed;?>'>
在这里你可以得到你所有的产品(你的"while"语句),使用一个计数器变量,然后:
<input type='hidden' name='amount_<?php echo $counter;?>' value='<?php $price ?>'>
<input type='hidden' name='item_name_<?php echo $counter;?>' value='<?php echo $product?>'>
<?php $counter++ ?>
最后关闭表单
</form>