【问题标题】:PayPal button as 'link' rather than 'form'PayPal 按钮作为“链接”而不是“表单”
【发布时间】:2015-03-17 06:47:03
【问题描述】:

我目前有以下 PayPal 按钮,其中包含通过 PHP 动态插入的值和“item_name”和“amount”。

<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="info@example.com">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="item_name" value="<?php echo $title; ?>">
<input type="hidden" name="amount" value="<?php echo $amount; ?>">
<input type="image" src="http://www.example.com/paypal-button.gif" border="0" name="submit" alt="Click here to pay now">
</form>

有没有办法将相同的数据集作为“链接”而不是“表单”?

我知道您可以通过他们的网站手动将 PayPal 按钮设置为链接、固定价格等,但我想使用 PHP 设置价格。

这样做的目的是使相同的代码可以用作要通过电子邮件发送的链接。

这可能是不可能的 - 任何帮助将不胜感激。

提前致谢。

【问题讨论】:

  • 你可以通过一些jquery来完成,添加一个链接并隐藏表单按钮,然后通过jquery在点击链接时提交表单。

标签: php email button paypal hyperlink


【解决方案1】:

我认为它可能会像这样工作。

<form class="clickformsubmit" name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
 <input type="hidden" name="cmd" value="_xclick">
 <input type="hidden" name="business" value="info@example.com">
 <input type="hidden" name="currency_code" value="GBP">
 <input type="hidden" name="item_name" value="<?php echo $title; ?>">
 <input type="hidden" name="amount" value="<?php echo $amount; ?>">
 <input style="display:none;" type="image" src="http://www.example.com/paypal-button.gif" border="0" name="submit" alt="Click here to pay now">
</form>
<a href="javascript:;" class="click_here">Click to send to paypal</a>

然后为此编写脚本

<script type="text/javascript">
 jQuery(function(){
   jQuery('.click_here').click(function(){
        jQuery('.clickformsubmit').submit();
   });
});
</script>

为此,您必须在页眉或页脚中包含 jQuery

**注意:**您可以使用$ 符号代替jQuery

【讨论】:

  • 非常感谢您的快速回复,这在浏览器中完美运行。我想我在使用这种方法在电子邮件中创建按钮时可能会寻找太多,可能不得不坚持使用标准的 PayPal 按钮。
猜你喜欢
  • 1970-01-01
  • 2011-10-16
  • 2010-10-10
  • 2012-08-23
  • 2018-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多