VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Jack Stiles on August 21, 2018, 19:30:28 PM

Title: Cart Icon Numbers Only
Post by: Jack Stiles on August 21, 2018, 19:30:28 PM
Hey guys - so I have this issue here. What I needed was to create a cart icon and put it to my menu header. But I ONLY needed icon + a tiny little number of how much products is in a cart. Something like shopify has in a top right corner:

https://debut-demo.myshopify.com/

So what I did - I have published a VM - Shopping cart module in a header and I used a CSS to disable everything except number. But - it say "2 items" for example and it also says "cart is empty" when theres nothing in a cart. I tried to edit default.php file in tmpl but I cannot find a way to get rid of those texts :-D I only need numbers like 2 or 15 or so... Is there a way to do it?

Btw. I am on latest Joomla and latest VMart. ;-)
Title: Re: Cart Icon Numbers Only
Post by: GJC Web Design on August 21, 2018, 19:57:10 PM
think $data->totalProduct is just a number ...  but don't think it updates by ajax - only on refresh

to ajax it add

$(module).find(".cart_total").html(datas.totalProduct);

to the vm cart mod js

Title: Re: Cart Icon Numbers Only
Post by: Jack Stiles on August 21, 2018, 20:22:12 PM
Wow! So your solution made me think and I found this line:

<div class="total_products"><?php echo  $data->totalProductTxt ?></div>

I simply removed the Txt and now I only have a numbers there :-) Thanks mate!
Title: Re: Cart Icon Numbers Only
Post by: GJC Web Design on August 21, 2018, 23:32:31 PM
then u will need to change in the js

$(module).find(".total_products").html(   datas.totalProductTxt);

to

$(module).find(".total_products").html(   datas.totalProduct);
Title: Re: Cart Icon Numbers Only
Post by: Jack Stiles on August 22, 2018, 11:30:07 AM
OK will do thank you!  ;)