I'd like to change the style of the add to wishlist button when the product is already in the wishlist, perhaps change the color of the heart icon into red.
How can I check if the product is already in the wishlist regardless if the user is logged-in or not.
Hoping for the best and detailed answers.
Opencart 2.3.0.2
The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.
Regards,
Straightlight
Programmer / Opencart Tester
I was talking about the status of the wishlist button on products. If the product is already in the wishlist, then set the button or the icon of the button to a red heart. If the product is not on the wishlist, then display the default button with the gray heart. Can this be really done only in stylesheet? Why is this not an opencart default function anyway?
Here is the default code that I want to change. See the wishlist part of the code:
Code: Select all
<div class="button-group">
<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span> <i class="fa fa-shopping-cart"></i></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>
</div>
viewtopic.php?t=153316
viewtopic.php?t=96874
But the solutions provided doesn't seem to work on my case. Maybe I didn't perform the solutions correctly as I only have a few knowledge on this.
Any help for a Newbie like me is very much appreciated

Code: Select all
if (isset($this->session->data['wishlist'])) {
$data['wishlist_test'] = in_array($product_id, $this->session->data['wishlist']);
}
This needs to go in the ../controller/product/product.php file above (around line 160):
Code: Select all
$product_info = $this->model_catalog_product->getProduct($product_id);
-
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS
Code: Select all
if (isset($this->session->data['wishlist'])) {
$data['wishlist_test'] = in_array($product_id, $this->session->data['wishlist']);
}
Code: Select all
$data['wishlist_test'] = false;
if (isset($this->session->data['wishlist'])) {
$data['wishlist_test'] = in_array($product_id, $this->session->data['wishlist']);
}
Code: Select all
{% if wishlist_text %}
... your true returned result code here ...
{% else %}
... your false returned result code here ...
{% endif %}
The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.
Regards,
Straightlight
Programmer / Opencart Tester
I have a commercial extension that can do that:
Add to Wishlist Button Switcher
https://www.opencart.com/index.php?rout ... n_id=37140
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Users browsing this forum: No registered users and 5 guests