我想添加一個「自定義」值到第三方結帳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