2015-09-04 106 views
1

我創建了我的購物車,它完美地適用於添加多個項目。然後這將循環每個項目,並顯示圖像,名稱,數量和總價格。貝寶購物車檢測到錯誤

我添加了一個PayPal按鈕,我試圖得到這個工作,但我不知道它爲什麼不撿東西了。我總是得到'檢測到錯誤,購物車中沒有任何東西'。

我還打印出我的變量,以確保它們是正確的,他們都是,但仍然看起來像是沒有得到形式回升。

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="cmd" value="_cart"> 
<input type="hidden" name="upload" value="1"> 
<input type="hidden" name="business" value="[email protected]"> 

for ($i = 0; $i < count($cart); $i++) { 
     $s += $cart[$i]->price * $cart[$i]->quantity; 
     $ppName = $cart[$i]->name; 
     $ppAmount = $cart[$i]->price * $cart[$i]->quantity; 
     $ppQuantity = $cart[$i]->quantity; 
     // Inside of for each loop 
     ?> 
     <input type="hidden" name="item_name_<?php echo $x; ?>" value="<?php echo $ppName; ?>"> 
     <input type="hidden" name="amount_<?php echo $x; ?>" value="<?php echo $ppAmount; ?>"> 
     <input type="hidden" name="quantity_<?php echo $x; ?>" value="<?php echo $ppQuantity; ?>"> 
     <tr> 
     <td class="col-md-2"><img class="img-responsive" img src= '<?php echo $cart[$i]->image_name; ?>' alt="Oops, Image cannot be found!" height="150" width="150"/></td> 
     <td class="col-md-4">Name: <?php echo $cart[$i]->name; ?><br><br> <?php echo $cart[$i]->description; ?></td> 
     <td class="col-md-4"> <a href="checkout.php?index=<?php echo $index; ?>" onclick="return confirm('Are you sure?')"><span class="glyphicon glyphicon-minus"></a></span> Qty <?php echo $cart[$i]->quantity; ?> <span class="glyphicon glyphicon-plus"></span></td> 
     <td><?php echo $cart[$i]->price * $cart[$i]->quantity; ?></td>   
     </tr> 
     <br> 
     <?php 
     $index++; 
     $x = $i + 1; 
     ?> 

<input type="hidden" name="currency_code" value="GBP"> 
<input type="hidden" name="hosted_button_id" value="2R2BAJEWK3LRU"> 
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online."> 
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> 

我將不勝感激任何反饋。 非常感謝。

回答

0

我發現包含在您的按鈕代碼hosted_button_id,一旦hotsted按鈕ID包含所有你添加的額外代碼無效。

請刪除「hosted_button_id」的行和重試。

+0

非常感謝你爲此工作:) – Brent