0
經過數週試圖讓我的Paypal付款窗體顯示項目列表後,我終於用我的代碼停止了錯誤消息,但是當我點擊在「購買」按鈕,並通過貝寶,貝寶說,我的購物車是空的,即使它沒有。_xcart在Paypal付款窗體上無法正常工作「您的購物車是空的」
我都回蕩着購物車的物品的cookie(使用PHP餅乾車),但由於某種原因,貝寶是沒有找到在車
這裏的項目是我的代碼:
cart.php
<?php
$page_title="Cart";
include 'includes/header.php';
$action = isset($_GET['action']) ? $_GET['action'] : "";
$name = isset($_GET['name']) ? $_GET['name'] : "";
if($action=='removed'){
echo "<div class='alert alert-info'>";
echo "<strong>{$name}</strong> was removed from your cart!";
echo "</div>";
}
$cookie = $_COOKIE['cart_items_cookie'];
$cookie = stripslashes($cookie);
$saved_cart_items = json_decode($cookie, true);
if(count($saved_cart_items)>0){
// get the product ids
$ids = "";
foreach($saved_cart_items as $id=>$name){
$ids = $ids . $id . ",";
}
// remove the last comma
$ids = rtrim($ids, ',');
//start table
echo "<table class='table table-hover table-responsive table-bordered'>";
// our table heading
echo "<tr>";
echo "<th class='textAlignLeft'>Product Name</th>";
echo "<th>Price (USD)</th>";
echo "<th>Action</th>";
echo "</tr>";
$query = "SELECT id, name, price FROM products WHERE id IN ({$ids}) ORDER BY name";
$stmt = $con->prepare($query);
$stmt->execute();
$total_price=0;
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
echo "<tr>";
echo "<td>{$name}</td>";
echo "<td>${$price}</td>";
echo "<td>";
echo "<a href='remove_from_cart.php?id={$id}&name={$name}' class='btn btn-danger'>";
echo "<span class='glyphicon glyphicon-remove'></span> Remove from cart";
echo "</a>";
echo "</td>";
echo "</tr>";
$total_price+=$price;
}
echo "<tr>";
echo "<td><b>Total</b></td>";
echo "<td>${$total_price}</td>";
echo "<td>";
echo "<a href='payment-page.php?total={$total_price}' class='btn btn-success'>";
echo "<span class='glyphicon glyphicon-shopping-cart'> </span> Checkout";
echo "</a>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
else{
echo "<div class='alert alert-danger'>";
echo "<strong>No products found</strong> in your cart!";
echo "</div>";
}
include 'includes/footer.php';
?>
這裏是我的PayPal按鈕鏈接到我的購物車代碼:
<form action="https://www.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="item_name_1" value="<?php echo $_COOKIE['cart_items_cookie'];?>">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Order#21874">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="amount" value="<?php echo $_GET['total'];?> ">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_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">
</form>
有什麼我失蹤?
我對此很新,並且已經爲此工作了好幾個星期了!
感謝任何幫助或建議