我想添加一个“自定义”值到第三方结帐PayPal选项。我遇到的问题是PHP变量正在屏幕上显示。我将购物车值传递给会话变量。定制PayPal结帐,包括PHP变量
if(isset($_SESSION['checkout'])){
$orderData = '<table border="1"><th style="width:80px">Item</th>
<th sytle="width:250px">Size</th>
<th style="width:60px">Quantity</th>';
for ($i=0; $i<count($_SESSION['checkout']); $i++){
$orderData .= '<tr><td style="text-align:center">'.$_SESSION['checkout'][$i][0].'</td><td style="text-align:center">'.$_SESSION['checkout'][$i][1].'</td><td style="text-align:center">'.$_SESSION['checkout'][$i][2].'</td></tr>';
}
}
我要传承下去该表,并根据PayPal documentation,所有我需要做的是包括它。我呼应了贝宝的形式是这样的:
echo '<form>
//other hidden values
<input type="hidden" name="custom" value="'.$orderData.'">
//input submit button here
</form>
就像我说的,输入应该被隐藏,但它得到PayPal按钮之前显示。怎么来的?
UPDATE:那些代码传递量完美:
<input type="hidden" name="amount" value="';?><?php if(isset($_SESSION['disc'])){print_r($_SESSION['disc']);}?><?php echo '">
它不会在网页上显示,但可变量是在页源正确。
UPDATE2:这是我整个车脚本:
echo '<div style="position:absolute; left:770px; top:50px">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Merchandise">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="custom" value="'.$orderData.'">
<input type="hidden" name="return" value="backtomywebsite.com">
<input type="hidden" name="cancel_return" value="backtomywebsite.com">
<input type="hidden" name="amount" value="';?><?php if(isset($_SESSION[$disc])){print_r($_SESSION[$disc]);}?><?php echo '">
<input type="image" src="http://www.mywebsite.com/images/BuyNow.png" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!" width="300" height="204">
</form>
</div>';
的脚本,而不是$ orderData当我有项目信息的print_r会话工作。该信息被发送到我的PayPal帐户,但它是一个数组形式,看起来很丑。如果有办法将所有东西(会员信息,订单信息)制作成一个php变量并将其传递到自定义字段中,那就太棒了。反正......这里就是出现在屏幕上:
希望你仍然愿意帮助我。
嘿,问题不在于金额,而是自定义输入字段。我的意思是价值正在显示在屏幕上,因为它不是隐藏的。具有名称custom和value $ orderData的输入不会隐藏,但会显示在屏幕上......并且,我将整个购物车值发送到PayPal,而不是单个项目。 – user2025469 2013-05-14 17:38:54
自定义变量不应显示在屏幕上。你能提供一个你所看到的屏幕截图,并链接到你的结帐,以便我可以通过并查看可能导致问题的原因。 – 2013-05-15 17:51:53
我用完整的代码和图像更新了我的帖子。希望你仍然关注这篇文章,即使我在这里错过了几天... – user2025469 2013-05-19 22:25:32