4 replies [Last post]
bara.munchies's picture
Offline
Joined: 08/18/2008
Juice: 32
Was this information Helpful?

i.e. i wanna display show amount of items of the shopping cart in my front-page.tpl.php
any ideas?

manatwo's picture
Offline
Joined: 02/19/2008
Juice: 235
Re: getting shopping cart variables outside of the shopping cart

This will get the number of items, then you just need to output them with php in your front page.

<?php

$items

= uc_cart_get_contents();
$item_count= count($items);
?>

This might also help:

http://www.ubercart.org/docs/api/uc_cart_get_contents

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: getting shopping cart variables outside of the shopping cart

If you only want to show the number of items in the cart, just do this in your template file... this is similar to how I do it on my site:

<?php
$items
= uc_cart_get_contents();
print
t('Cart: !items', array('!items' => format_plural(count($items), '@count item', '@count items')));
?>

--
Help directly fund development: Donate via PayPal!

bara.munchies's picture
Offline
Joined: 08/18/2008
Juice: 32
Re: Re: getting shopping cart variables outside of the shopping

thanks guys, that was really fast.

tr3online's picture
Offline
Joined: 03/23/2011
Juice: 26
Re: Re: getting shopping cart variables outside of the shopping

This seems to only put the item type count. For instance, if I add two different items into the cart, it counts it as "2". However, if I have two different items, but 14 of type 1, it still displays "2" and not 15.
Is there any ways to fix this?