如何从购物车获得多种产品到贝宝付款

时间:2015-08-05 05:43:45

标签: php paypal e-commerce

我想在paypal支付页面上获得多个产品。我目前只收到第一件产品。谁能帮我解决我错的地方。下面是我的代码..我搜索谷歌,发现还有两件事要改变。即_xclick to _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;?>'>


}

}

1 个答案:

答案 0 :(得分:2)

如果是多种产品,您必须为每种产品使用以下变量: 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;?>'>

在这里,您可以获得所有产品(您的&#34; while&#34;语句),使用计数器变量,然后:

    <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>