Author Topic: how to get number of products in cart  (Read 136 times)

kiasati

  • Jr. Member
  • **
  • Posts: 85
  • A beginner
how to get number of products in cart
« on: February 07, 2018, 14:26:31 pm »
Hi

I have a simple button at the the top of my site that points to the cart page.
I want to show the number of product that are in the cart.
whats the code for it?

I wanna put this code in template index.php file. so i want it to be clean and fast so it wont effect page load time even a little bit.

i appreciate any help...

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9487
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: how to get number of products in cart
« Reply #1 on: February 10, 2018, 22:17:51 pm »
a kind of echo count($cart->products). You just need to check if you have $cart or $this->cart
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 2741
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: how to get number of products in cart
« Reply #2 on: February 11, 2018, 01:36:31 am »
You can not dispay directly the product in cart in index.php.
You get this from Vm session or you need to initialise the cart(see mod_virtuemart_cart for the code)