RockyRocks Posted May 31, 2013 Share Posted May 31, 2013 (edited) hey, frnds.....Is there any way to put 'Compare' button like view and add to cart button on each product in product-listing page..?? What i want to do is when i click on 'Compare' button the product must add to comparison list... thx... Edited May 31, 2013 by RockyRocks (see edit history) Link to comment Share on other sites More sharing options...
RockyRocks Posted June 15, 2013 Author Share Posted June 15, 2013 No-one can help me....??? Link to comment Share on other sites More sharing options...
PascalVG Posted June 16, 2013 Share Posted June 16, 2013 Don't you have the check boxes that give this functionality now? Selecting the boxes of the products you want to compare and then press compare...?? Link to comment Share on other sites More sharing options...
RockyRocks Posted June 19, 2013 Author Share Posted June 19, 2013 thanks for reply....PascalVG..... As you said i have a compare button on top of the Product-listing page and Check boxes given in each product<li>....But i don't want this functionality.... Actually, i want a compare button on each product<li> (near ADD TO CART & VIEW buttons) on product-listing page and Don't want check boxes on page.....whenever i click on COMPARE button, that product should be added directly to PRODUCT-COMPARISON page..... Link to comment Share on other sites More sharing options...
Aditya Kaushik Posted January 3, 2015 Share Posted January 3, 2015 Add this code in "product.tpl" where you want to place the "Add to Compare button", code is working fine with Prestshop 1.6 version too --and consists of javascript code /ajax function to add a product to comapre. Use this code and Enjoy B) :D <!--Add to Compare----> <script type=\"text/javascript\">function addToCompare() { var totalValueNow = parseInt($('.bt_compare').next('.compare_product_count').val()); var totalVal; if(totalValueNow<3){ $.ajax({ url: 'index.php?controller=products-comparison&ajax=1&action=add&id_product=' + {$product->id|intval}, async: true, cache: false, type: 'Post', dataType: 'html' }); compareButtonsStatusRefresh(); totalVal = totalValueNow +1, $('.bt_compare').next('.compare_product_count').val(totalVal), totalValue(totalVal); $('.bt_compare').attr("disabled",false); $('.bt_compare').css("background-color","#E8490C"); $('.bt_compare').css("color","#fff"); } else{ var $div8 = $(".comapare_max_limit"); if ($div8.is(":visible")) { return; } $div8.show(); setTimeout(function() { $div8.hide(); }, 4000); var $div9 = $(".product-added_overlay"); if ($div9.is(":visible")) { return; } $div9.show(); setTimeout(function() { $div9.hide(); }, 4000); } } function totalValue(value){ $('.bt_compare').find('.total-compare-val').html(value);} function compareButtonsStatusRefresh() { $('.add_to_compare').each(function() { if ($.inArray(parseInt($(this).data('id-product')), comparedProductsIds) !== -1) $(this).addClass('checked'); else $(this).removeClass('checked'); });} </script> {if isset($comparator_max_item) && $comparator_max_item} <a onclick="addToCompare()" href="#" data-id-product="{$product->id|intval}"><span class="product_btn_comparison">Add to Compare</span></a> <div class="comapare_max_limit">You cannot add more than 3 product(s) to the product comparison</div> {/if} {include file="./product-compare.tpl"} <!------> Link to comment Share on other sites More sharing options...
Recommended Posts