The following function should do the job to calculate the number of items in the shopping cart:
function simple_cart_total_itmes()
{
$total = 0;
foreach ($_SESSION['simpleCart'] as $item)
{
$total ++;
}
return $total;
}The following function should do the job to calculate the number of items in the shopping cart:
function simple_cart_total_itmes()
{
$total = 0;
foreach ($_SESSION['simpleCart'] as $item)
{
$total ++;
}
return $total;
}Is this to find out the number of line items or the number of line items + quantity of each line item?
Where would I put this function?
I want to use it as a tool to discount the total based on how many individual items are ordered. with discounts increasing with each additional line item (up to 4)
any suggestions?
Rob
This is to find out the number of line items.
So, if I had 4 cans of Chicken Noodle Soup, and 3 cans of Mushroom Roup; the number is 7, right?
Nope, the number of line items in the cart would be 2. The total quantity would be 7 (I don't know what to call this :)
I'm gonna try that reasoning the next time I use the 10 item express lane at the supermarket, LOL!
You must log in to post.