News:

Support the VirtueMart project and become a member

Main Menu

How to display number of products in cart?

Started by samlf3rd, March 26, 2013, 14:20:33 PM

Previous topic - Next topic

PRO

Quote from: Tenuw on May 01, 2013, 22:10:56 PM
Hi.

I'm on Virtuemart: 2.0.6a/Joomla: 2.5.6

I've tried:

<?php
if ( $product['quantity'] < 1) {
echo "0 Item(s)";
}
else {
echo  $product['quantity'];
}
?>

in the default.php > mod_virtuemart_cart

It displays '0 Item(s)', but when adding to the cart, it still displays '0 Item(s)'.

Has anyone got a definitive answer?

I'd also like to know how to display 'Item(s)' when more items are added to the cart. I've tried this:

<?php
if ( $product['quantity'] < 1) {
echo "0 Item(s)";
}
else {
echo  $product['quantity']("Item(s)");
}
?>

but I don't know if it works, as the previous code which I adapted from isn't updating the Item(s).

Many thanks.

The javascript file vmprices.js    is what updates this,.


what happens when you update the page?

does it change?

Tenuw

Hi Pro

Thanks for your reply.

I don't know enough about Javascript to convert the PHP code into something meaningful for vmprices.js to function the way I'd like to. Any advice?

Many thanks.

Kind regards.


PRO

whats wrong with the current version of the module?

what do you want it to be different like?


Tenuw

Hi Pro

Thanks for your reply.

I just need less information than whats normally in the cart. Please see the attachment example.

I thought the original PHP code would achieve what I'm after. But as you recommended looking at vmprices.js, I don't actually know how to code javascript for this purpose. If you can help, great. If you can't, I understand.

Many thanks.

Kind regards.

[attachment cleanup by admin]

PRO

look at my site

& add an item to the cart

this is my whole file for

mod_virtuemart_cart/tmpl/default.php


<?php 
//no direct access
defined('_JEXEC') or die('Restricted access');
?>
<div class="vmCartModule" id="vmCartModule"><div id="carticon" class="inline"></div><div class="total_products width59 inline"><?php echo  $data->totalProductTxt ?></div><div class="show_cart floatRight width40 bold"><?php if ($data->totalProduct) echo '<div class="floatRight">'. $data->cart_show .'</div>';?></div><div class="wrap"></div></div>

Tenuw

Hi Pro

Thanks for your reply.

I tried your code. It worked, thank you!

Many thanks, and good day to you!

Kind regards.