【问题标题】:Paypal button add to shoping cartPaypal 按钮添加到购物车
【发布时间】:2016-09-28 12:31:54
【问题描述】:

我正在尝试添加“添加到购物车”按钮。但是现在当我使用按钮时会发生这样的事情: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>

我将发布显示购物车按钮的代码,但我想它没有问题,因为它工作正常:

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

【问题讨论】:

    标签: php html paypal


    【解决方案1】:

    您创建的代码用于“购物车上传”功能。它通常在您的网站中嵌入了一些购物车功能并将购物车的内容传递给 PayPal 以进行结帐和付款处理时使用。

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

    请查看以下链接以获取“添加到购物车”按钮的示例代码。

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 非常感谢。但是我的问题的另一部分是我是否可以单击添加到购物车按钮,并且不会被重定向到购物车。可能吗? @pp_pduan
      • 使用购物车按钮时,您将无法停留在页面上。您可以考虑使用开源购物车系统(例如 Magento、OpenCart)来实现这一目标
      猜你喜欢
      • 2015-12-21
      • 1970-01-01
      • 2012-10-04
      • 2011-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      相关资源
      最近更新 更多