Magento Asked by jykmhar123 on October 2, 2021
please anyone help me
<a href="#" data-post='<?php echo $this->helper('MagentoWishlistHelperData')->getAddParams($_product) ?>' class="action towishlist" data-action="add-to-wishlist" id="hasitem-wish"></a>
<!-- /ko -->
<!-- ko ifnot: wishlist().getProductUrl() -->
<a href="#" data-post='<?php echo $this->helper('MagentoWishlistHelperData')->getAddParams($_product) ?>' class="action towishlist" data-action="add-to-wishlist"></a>
<!-- /ko -->
it will help you to solve this issue.
$_helper = $this->helper('MagentoCatalogHelperOutput');
$_product = $block->getProduct();
<div class="link wishlist">
<a href="#" data-post='#' class="action towishlist wish-in-wish" id="hasitem-wish"></a>
<a href="#" data-post='<?php echo $this->helper('MagentoWishlistHelperData')->getAddParams($_product) ?>' class="action towishlist wish-notin-wish" data-action="add-to-wishlist"></a>
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"wishlist": {
"component": "Magento_Wishlist/js/view/wishlist"
}
}
}
}
}
</script>
<script type="text/javascript">
sh(document).ready(function()
{
sh('.wish-in-wish').hide();
var title = sh('.catalog-product-view .product-info-main .product .page-title .base').text();
var md = localStorage.getItem('mage-cache-storage');
var myJSON = JSON.parse(md);
var wishlistdata = myJSON.wishlist.items;
wishlistdata.forEach(function(item)
{
var wishlistpn = item.product_name;
if (wishlistpn == title)
{
sh('.wish-in-wish').css("display","block");
sh('.wish-notin-wish').hide();
}
});
var guest_wishlistdata = myJSON.guest_wishlist.items;
guest_wishlistdata.forEach(function(item)
{
var gstwishlistpn = item.product_name;
if (gstwishlistpn == title)
{
sh('.wish-in-wish').css("display","block");
sh('.wish-notin-wish').hide();
}
});
});
</script>
I solve this issue using this way. it will check checklist form localstorage without getting info from server side.
Correct answer by jykmhar123 on October 2, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP