Bearcat
09-15-2003, 07:17 PM
I'am looking for code that show item in a shopping cart to put on my front page the person can see what in there cart can anyone help me out with this?
Like it would said "You have 1 item in your shopping cart."
or this "You have no items in your cart."
and this "The total Price is $5.00"
This is going to depend entirely how the shopping cart is written/works...
Bearcat
09-15-2003, 08:57 PM
What do you mean? Did you ever hear of a Software ppalCart2_2 that what shopping cart is in.
No, sorry. I'm not framiliar with it...
Bearcat
09-15-2003, 10:07 PM
It have paypal in but right hear is all it have in it
<form onSubmit="return checkFields()" 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="business" value="<?php echo $ppalAccount; ?>">
Can i add the code that show item in a shopping cart to put on my front page the person can see what in there cart ? Because that all of paypal code i see.
Ah, PayPal... Hmm. I don't know of anyway to do it, but there may be one. Did you try searching Google? Sorry 'bout that...
Bearcat
09-15-2003, 10:19 PM
No i don't try that Because i don't know what really to searching for. Here my some of my cart page you can see what it like and what you think.
<script language="php">
// find out what you want to do with the cart with action variable and act accordinly
global $action, $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $updater;
if($action == "add_item") {
AddItem();
ShowCart();
}
if($action == "update_item") {
UpdateItem();
ShowCart();
}
if($action == "update_option") {
UpdateItemOption();
ShowCart();
}
if($action == "remove_item") {
RemoveItem();
ShowCart();
}
if($action == "empty_cart") {
EmptyCart();
ShowCart();
}
if(!$action) {
ShowCart();
}
function AddItem()
{
global $eurocash, $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost, $catId;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
$result = mysql_query("select * from cart where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn't exist in the users cart,
// we will add it with an insert query
$query = "INSERT INTO cart VALUES ('$cartId', '$itemId', '$qty', '$itemoptions', '$shortdesc', '$longdesc', '$prodprice', '$catId')";
$result = MYSQL_QUERY($query);
}
else
{
// This item already exists lets update it.
$query = "UPDATE cart set qty = qty + '$qty' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'";
$result = MYSQL_QUERY($query);
}
}
function UpdateItem()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
// Updates the quantity of an item in the users cart.
// If the qutnaity is zero, then RemoveItem will be
// called instead
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
mysql_query("update cart set qty = '$qty' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
}
function UpdateItemOption()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost, $prevoption;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
$result = mysql_query("select * from cart where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This items size doesn't exist in the users cart,
// we will update old with an insert query
mysql_query("update cart set itemoptions = '$itemoptions' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$prevoption'");
}
else
{
mysql_query("update cart set qty = qty + '$qty' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
mysql_query("delete from cart where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$prevoption'");
}
}
function RemoveItem()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
mysql_query("delete from cart where cartId like '$cartId' and itemId like '$itemId' and itemoptions like '$itemoptions'");
}
function EmptyCart()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
mysql_query("delete from cart where cartId like '$cartId'");
}
function ShowCart()
{
global $shipTotal, $grandTotal, $usdollarcost, $usdollar, $usdollartotalcost, $gbpoundcost, $gbpoundtotalcost, $gbpound, $prodprice, $gbpoundcost, $imageProdFolder, $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
$grandTotal = 0;
$totalCost = 0;
$itemcount = 0;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
$result = mysql_query("select * from cart where cartId = '$cartId'");
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all items
$prodprice = $row["prodprice"];
$prodtotalcost = number_format($row["qty"] * $row["prodprice"], 2, ".", ",");
$totalCost += $row["qty"] * $row["prodprice"];
$itemname = $row["itemId"];
$totalOption = $row["itemoptions"];
$optionitem = $row["itemId"];
$optionitemqty = $row["qty"];
$gbpoundcost = $prodprice * $gbpound;
$gbpoundcost = number_format($gbpoundcost, 2, ".", ",");
$usdollarcost = $prodprice * $usdollar;
$usdollarcost = number_format($usdollarcost, 2, ".", ",");
$eurocashcost = $prodprice * $eurocash;
$eurocashcost = number_format($eurocashcost , 2, ".", ",");
</script>
Hey that ok
You should just be able to use the ShowCart function...
Bearcat
09-15-2003, 10:33 PM
How would i do that like this
function ShowCart(){
if($ShowCar!=0 && $ShowCar!=1){
echo "You have " . $ShowCar . " items in your shopping cart.";
}elseif($ShowCar==1){
echo "You have 1 item in your shopping cart.";
}else{
echo "You have no items in your cart.";
}
}