Smoking Sheriff
Smoking Sheriff

Reputation: 471

Show cart item count and total calculated price in osCommerce template

How can I show the cart item count and total calculated price in the template_top.php file in osCommerce?

I have the following code in my template file and would like to have the numbers update as the cart does:

<span class="items">10 items</span>   |   <span>$500.00</span>

Upvotes: 0

Views: 2911

Answers (1)

random
random

Reputation: 9955

To show the total number of items in your shopping cart, you'll want to call the following:

$cart->count_contents()

For the total cost of items in your cart, then you'll want this:

$cart->show_total()

echo them out as needed wherever on the template you want them to show.

In your case it would be as follows (broken across two lines for visual display here):

<span class="items"><?php echo $cart->count_contents() ?> items</span> | 
<span><?php echo $cart->show_total() ?></span>

Both of these are defined in the shopping cart class, located at: includes/classes/shopping_cart.php

Upvotes: 1

Related Questions