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...
a kind of echo count($cart->products). You just need to check if you have $cart or $this->cart
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)
Hi.
Old topic i know, but...
vm3.2.15 J3.8.11
How could I get the amount of all products in component cart in overide of course?
I was trying to find something in $cart->products, but i can't find anything of which i could count. I know this can be done becouse cart module is doing it, but that is in $data->totalProductTxt and I stack on how to call it in component cart or calculate for my own in override component cart file. (scenario 2 products. first x 3 , second x5, and all i get was 2 as the products amount, without products quanatity. I need to get 8 :) )
Thanks for any advise or sugestion.
Quote from: bart198x on August 02, 2018, 22:57:21 PM
Hi.
Old topic i know, but...
vm3.2.15 J3.8.11
How could I get the amount of all products in component cart in overide of course?
Do a var_dump($data)
You should see products array and each have quantity
you need to get the cart by the means discussed above and loop thru the $cart products and accumulate the products*quantity to get the total
$total_prods = 0;
foreach ($this->cart->products as $product){
$total_prods+= $product->quantity ;
}
these aren't the actual vars.. check the cart object
GJC thanks a lot, that works :)