检测到贝宝购物车错误
Paypal shopping cart Error Detected
我已经创建了我的购物车,它非常适合添加多个项目。然后这将遍历每个项目并显示图像、名称、数量和总价。
我添加了一个 paypal 按钮并试图让它工作,但我不确定为什么它没有接收到任何东西。我总是 'Error Detected, nothing in shopping cart'.
我还打印出我的变量以确保它们是正确的,但看起来它仍然没有在表格中被拾取。
<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="business@gmail.com">
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">
如果有任何反馈,我将不胜感激。
非常感谢。
我发现你的按钮代码中包含hosted_button_id,一旦包含热门按钮id,你添加的所有额外代码均无效。
请删除 "hosted_button_id" 行并重试。
我已经创建了我的购物车,它非常适合添加多个项目。然后这将遍历每个项目并显示图像、名称、数量和总价。
我添加了一个 paypal 按钮并试图让它工作,但我不确定为什么它没有接收到任何东西。我总是 'Error Detected, nothing in shopping cart'.
我还打印出我的变量以确保它们是正确的,但看起来它仍然没有在表格中被拾取。
<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="business@gmail.com">
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">
如果有任何反馈,我将不胜感激。 非常感谢。
我发现你的按钮代码中包含hosted_button_id,一旦包含热门按钮id,你添加的所有额外代码均无效。
请删除 "hosted_button_id" 行并重试。