sala2001 Posted November 4, 2014 Share Posted November 4, 2014 (edited) Hello, I found out there's a big problem with product compare : if you refresh the page, the previously checked products are now unchecked so you cannot remove them from the compare. Tried on the demo shop, same bug : Go to http://fo.demo.prestashop.com/en/8-dresses , check 3 products to compare, refresh the page and now they are unchecked but still in the comparator so you cannot remove them except if you check again then uncheck but even there there's no way to know if they are removed (they are in fact) because the Compare (3) stays the same except there are now 2 products in the compare. This is a big issue, someone got a work-around? Either to remove all products from compare when changing page or to keep checked the checked products when you come back. Else there's no other way to remove the products from the comparator without going to the compare page. Edited November 4, 2014 by sala2001 (see edit history) Link to comment Share on other sites More sharing options...
sala2001 Posted November 4, 2014 Author Share Posted November 4, 2014 Well after a few tries I sort of figured out where the problem is but since i'm not good in JS I can't manage to solve it . When I try {if isset($compared_products) && in_array($product.id_product, $compared_products)} in the tpl file it detects wich products are checked and check them but the javascript code uncheck them. The value is passed by {addJsDef comparedProductsIds=$compared_products} at the end of the tpl but this part of the JS code in product-compare.js seems to be the problem as if the value of comparedProductsIds was not passed (or maybe the JS code is wrong I don't know): function compareButtonsStatusRefresh() { $('.add_to_compare').each(function() { if ($.inArray(parseInt($(this).data('id-product')), comparedProductsIds) !== -1) $(this).addClass('checked'); else $(this).removeClass('checked'); }); } ($.inArray(parseInt($(this).data('id-product')), comparedProductsIds) is always equal to -1 so it will always remove the checked boxes even if in the tpl it detects correctly comparedProductsIds on each product. (I can even see the box uncheckng itself) I will continue to try to solve the issue and update you but please if someone could give me any hint, I'm a bit lost in this JS code. And this issue concerns every user of Prestashop 1.6 Link to comment Share on other sites More sharing options...
sala2001 Posted November 4, 2014 Author Share Posted November 4, 2014 Ok for all those have the problem I found a solution : https://github.com/PrestaShop/PrestaShop/commit/cfd25d0df7286e19b5ae9fba4067b339d764196b 1 Link to comment Share on other sites More sharing options...
moy2010 Posted March 25, 2015 Share Posted March 25, 2015 Hi, sala2001. I've a checkbox for compare products, but it's not working. This is the code:<input type="checkbox" class="comparator" id="comparator_item_{$product.id_product}" value="comparator_item_{$product.id_product}" {if isset($compared_products) && in_array($product.id_product, $compared_products)}checked="checked"{/if} /> The problem is that it's not submitting the products for the comparison form as expected .Did you have this kind of problem too? Link to comment Share on other sites More sharing options...
Recommended Posts