Post by VHalek » Fri Jun 04, 2010 8:39 pm

Hello,
don't you know how to get number "total quantity of products" in the cart in the right column? Right now, I've got just total price, but I'd like to have something like:
You have 3 items, total price is 100GBP
Thank you very much.

Newbie

Posts

Joined
Mon May 31, 2010 6:10 am

Post by JAY6390 » Sat Jun 05, 2010 6:17 am

Are you wanting the total stock or the quantity of different products?
Lets say you have
3 x LCD Screen
2 x iPod

Do you want the number 2 since there are 2 different products, or 5 since there are a total of 5 products in the cart

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by VHalek » Sat Jun 05, 2010 6:28 am

If we have this situation (with your products), I'd like to have this written in the cart:
You have 5 items, total price is xxx.

Newbie

Posts

Joined
Mon May 31, 2010 6:10 am

Post by JAY6390 » Sat Jun 05, 2010 6:48 am

You can put this in your template wherever you want it

Code: Select all

<?php echo $this->cart->countProducts(); ?>
@OC developers - The cart function to this can be simplified
Current code:

Code: Select all

      public function countProducts() {
        $total = 0;
        
        foreach ($this->session->data['cart'] as $value) {
            $total += $value;
        }
        
        return $total;
      } 
Simplified:

Code: Select all

public function countProducts() {
    return array_sum($this->session->data['cart']);
} 

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by VHalek » Sat Jun 05, 2010 7:37 am

Thank you very much, that's exactly what I was looking for.

Again - thank you.

Newbie

Posts

Joined
Mon May 31, 2010 6:10 am

Post by JAY6390 » Sat Jun 05, 2010 8:29 am

No problem :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by orientcart » Tue Apr 01, 2014 10:03 am

I can not find any extension for this, anyone can help me out ???

Newbie

Posts

Joined
Sat Feb 22, 2014 10:12 am

Post by pauliakas » Wed Feb 09, 2022 9:45 pm

Maybe someone has working code for 3.0.2.0 version?

Newbie

Posts

Joined
Mon Feb 11, 2019 5:40 pm


Post by OSWorX » Thu Feb 10, 2022 7:47 pm

pauliakas wrote:
Wed Feb 09, 2022 9:45 pm
Maybe someone has working code for 3.0.2.0 version?
Should be the same code.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 30 guests