Hi all,
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
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
This can be changed via your stylesheet.css file of your custom theme.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hi straightlight,
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:
I've found these 2 similar forum posts:
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
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
Since it is about defining a true or false statement, and that the array hasn't been defined before the IF statement or without validating the IF statement from the TWIG file, the validation may fail.
should be replaced with:
or from the related TWIG file:
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 %}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hi
I have a commercial extension that can do that:
Add to Wishlist Button Switcher
https://www.opencart.com/index.php?rout ... n_id=37140
I have a commercial extension that can do that:
Add to Wishlist Button Switcher
https://www.opencart.com/index.php?rout ... n_id=37140
And here's a free solution: Better Wishlist Button.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Who is online
Users browsing this forum: danieljarquin and 27 guests