Okay, I've searched and searched...I'm not finding the answer to my problem here. I'm trying to get the shopping cart to load to PayPal. It keeps telling me the shopping cart is empty, but on the site...it has stuff in it.
Anywho...I think my form information might be in the wrong place, but I can't seem to find the right place it should be.
I'm not sure if anyone will need more code. Here is the code that I think is the problem:
// Connect
require_once ("/config.inc");
$display_block = "<h1>Nascar Drivers - Shopping Cart</h1>
<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">";
//check for cart items
$get_cart_sql = "SELECT sc.sp_num, p.product_num, p.product_name, p.product_price, sc.sel_item_qty
FROM shopping_cart AS sc
LEFT JOIN product AS p
ON p.product_num = sc.sel_item_id
WHERE session_id = '".$_COOKIE["PHPSESSID"]."'";
$get_cart_res = mysql_query($get_cart_sql, $db_connection) or die(mysql_error());
if (mysql_num_rows($get_cart_res) < 1 ) {
$display_block = "
<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" width=\"100%\">
<tr><br /><p align=\"left\">You have no items in your cart.
Please <a style=\"text-decoration: none\" href=\"seestore.php\">continue to shop</a>!</p></tr></table>";
} else {
$display_block .= "
<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" width=\"100%\">
<tr>
<th align=\"right\">Product ID</th>
<th align=\"left\">Product</th>
<th align=\"right\">Qty</th>
<th align=\"right\">Price</th>
<th align=\"right\">Total Price</th>
<th align=\"center\">Action</th>
</tr>";
$total_cart=0;
setlocale(LC_MONETARY, 'en_US');
while ($cart_info = mysql_fetch_array($get_cart_res)) {
$id = $cart_info['sp_num'];
$product_num = $cart_info['product_num'];
$product_name = stripslashes($cart_info['product_name']);
$product_price = $cart_info['product_price'];
$product_qty = $cart_info['sel_item_qty'];
$total_price = sprintf('%.2f', $product_price * $product_qty);
$display_block .= "
<tr>
<td align=\"right\">$product_num <br /></td>
<td align=\"left\">$product_name <br /></td>
<td align=\"right\">$product_qty <br /></td>
<td align=\"right\">$" .$product_price. "<br /></td>
<td align=\"right\">$" .$total_price. "<br /></td>
<td align=\"center\"><a style=\"text-decoration: none\" href=\"removefromcart.php?id=".$id."\">Remove</a></td>
</tr>";
$total_cart += $total_price;
} //END WHILE
switch(TRUE){
case (0 <= $total_cart && $total_cart < 25):
$shipping_total = 5.95;
break;
case (25.01 <= $total_cart && $total_cart < 50):
$shipping_total = 7.95;
break;
case (50.01 <= $total_cart && $total_cart < 75):
$shipping_total = 10.95;
break;
case (75.01 <= $total_cart && $total_cart < 100):
$shipping_total = 14.95;
break;
case (100.01 <= $total_cart && $total_cart < 9000):
$shipping_total = 0;
break;
}
$shipping_cost = $shipping_total;
$display_block .= "
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>Shipping Total:</td>
<td align=\"right\">$" . sprintf('%01.2f', $shipping_cost) . "</td>
<td> </td></tr>";
$total_amount = $total_cart+$shipping_cost;
$display_block .= "
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>Grand Total:</td>
<td align=\"right\">$" . sprintf('%01.2f', $total_amount) . "</td>
<td> </td></tr></table>";
$display_block .= "<p>Would you like to <a href=\"seestore.php\">continue to shop</a>?</p>";
$display_block .= "<table>
<input type=\"hidden\" name=\"cmd\" value=\"_cart\"/>
<input type=\"hidden\" name=\"upload\" value=\"1\"/>
<input type=\"hidden\" name=\"business\"
value=\"greg@gregsgoods.com\"/>
<input type=\"hidden\" name=\"product_name\"
value=\"".$_GET["product_name"]."\"/>
<input type=\"hidden\" name=\"product_price\" value=\"".$_GET["product_price"]."\"/>
<input type=\"submit\" value=\"Pay with PayPal\"/>
</form></table>";
}
echo $display_block;