Post by Loxie » Mon Aug 30, 2010 4:18 am

I'd like to display the total number of items in the cart somewhere on the site, how would I go about initializing that in the templates? Would I have to sum up $product['quantity'] or is there a faster method?

An example of expected results of:
1 x foo
3 x bar

4 items in the cart.

Newbie

Posts

Joined
Mon Aug 30, 2010 4:15 am

Post by Maansy » Mon Aug 30, 2010 5:27 am

check out my sig :)

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by Loxie » Sat Sep 04, 2010 3:54 pm

I want to add the total number of items in the module and have it updated with the ajax thing as you click "add to cart". Your method only adds to the header?

I've tried hacking the code in the cart.tpl file, but when the ajax updates the module my changes don't get made at all. But when I reload the page, the changes are there. Do you know how to change what the ajax function updates for the cart?

I did something like this to the cart.tpl file:

Code: Select all

$totalquantity = 0;
foreach ($products as $product) {
  $totalquantity += $product['quantity'];
...
and somewhere else in the same file I put:

Code: Select all

echo $totalquantity;

Newbie

Posts

Joined
Mon Aug 30, 2010 4:15 am

Post by Loxie » Sat Sep 04, 2010 4:04 pm

Ah I figured out you have to edit the ../catalog/controller/module/cart.php file also in order to do it.

For anyone else that wants to do I wanted to do, you just have to add your changes in cart.tpl to the $output string in the cart.php file stated above.

Newbie

Posts

Joined
Mon Aug 30, 2010 4:15 am
Who is online

Users browsing this forum: No registered users and 4 guests