Paypal按钮添加到购物车

时间:2016-05-30 15:55:53

标签: php html paypal

我正在尝试添加购物车按钮。但是现在当我使用按钮时会发生什么:http://imgur.com/ldEEOK3

点击它时我想要按钮,它会将产品添加到购物车,并保持在同一页面。

<tr class="record">

    <td><?php echo $row['ref']; ?></td>
    <td><?php echo $row['nome']; ?></td>
    <td><?php echo $row['preco']; ?></td>
    <td><form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="paypalID"> //not gonna show it :p

<input type="hidden" name="item_name_1" value="<?php echo $row['nome']; ?>">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="amount_1" value="<?php echo $row['preco']; ?>">

<input type="image" src="https://www.paypalobjects.com/pt_PT/PT/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="PayPal - A forma mais fácil e segura de efetuar pagamentos online!">
<img alt="" border="0" src="https://www.paypalobjects.com/pt_PT/i/scr/pixel.gif" width="1" height="1">
</form>
</tr>

我将发布show cart按钮的代码,但我认为它没有问题,因为它工作正常:

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" > <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="encrypted" value="erased the big encrypt code"> <input type="image" src="https://www.paypalobjects.com/pt_PT/i/btn/btn_viewcart_SM.gif" border="0" name="submit" alt="PayPal - A forma mais fácil e segura de efetuar pagamentos online!"> <img alt="" border="0" src="https://www.paypalobjects.com/pt_PT/i/scr/pixel.gif" width="1" height="1"> </form>

2 个答案:

答案 0 :(得分:1)

您可能想要更改“添加到购物车”按钮中的一些变量:

<form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="paypalID"> //not gonna show it :p

<input type="hidden" name="item_name" value="<?php echo $row['nome']; ?>">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="amount" value="<?php echo $row['preco']; ?>">

<input type="image" src="https://www.paypalobjects.com/pt_PT/PT/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="PayPal - A forma mais fácil e segura de efetuar pagamentos online!">
<img alt="" border="0" src="https://www.paypalobjects.com/pt_PT/i/scr/pixel.gif" width="1" height="1">
</form>

答案 1 :(得分:1)

您创建的代码用于&#34;购物车上传&#34;功能。它通常用于您的网站中嵌入了某些购物车功能,并将购物车的内容传递给PayPal进行结帐和付款处理。

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/cart_upload/

请查看以下链接,了解&#34的示​​例代码;添加到购物车&#34;按钮。

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/paypal_shopping_cart/#id08AEC030FDB