Post by spyder » Mon Mar 04, 2013 9:09 pm

Hi guys,

Does anyone have a solution to this?
I want to check if there are any products added in the wishlist but couldn't find anything regarding this task. I know how to check if an user is logged in or not, but can't check if there are any products in the wishlist.

It should be something like this:

Code: Select all

if ($wishlist_products_available) {
     //your code here
}
Thanks for your efforts!

Newbie

Posts

Joined
Fri Sep 14, 2012 7:56 pm

Post by spyder » Tue Mar 05, 2013 12:02 am

No one??
I need help, please!

Newbie

Posts

Joined
Fri Sep 14, 2012 7:56 pm

Post by qahar » Tue Mar 05, 2013 12:36 am

First you need to check if wishlist is available, then check if product_id is in wishlist array

Code: Select all

if (isset($this->session->data['wishlist'])) {
  if (in_array($product_id, $this->session->data['wishlist'])) {
    echo 'do something';
  }
} 
Not really read your question. If you want to know if products in wishlist you can use :

Code: Select all

$wishlist = (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0) 
It will return 0 if wishlist is empty or not set.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by spyder » Wed Mar 06, 2013 11:36 pm

Thank you qahar!

It worked like a charm! :)
Yes, i wanted to know if there are products in wishlist... the second solution was great!

Newbie

Posts

Joined
Fri Sep 14, 2012 7:56 pm

Post by dyulo » Thu May 02, 2019 4:27 pm

Do we have a solution like this for Opencart 2.3.0.2?

Newbie

Posts

Joined
Wed Feb 27, 2019 7:30 pm
Who is online

Users browsing this forum: Bing [Bot] and 16 guests