Problem with multiple “Filter by Brand” widgets in the same page
-
Hello,
There is a problem when there are multiple “Filter by Brand” widgets in the same page.
The problem is that when you build the query for the url with javascript, the script adds multiple times the same brand (eg. ?pwb-brand-filter=bestway,carroten,garnier,carroten,garnier).I have the solution for the problem, you only have to review it and add it in your next release.
Thanks!
Fix
// Added 'element' as function parameter var PWBFilterByBrand = function (element) { var baseUrl = [location.protocol, '//', location.host, location.pathname].join(''); var currentUrl = window.location.href; // Added this line var $parent = $(element).closest('.pwb-filter-products'); var marcas = []; // Changed this line $parent.find('input[type="checkbox"]').each(function (index) { if ($(this).prop('checked')) marcas.push($(this).val()); }); marcas = marcas.join(); if (marcas) { ...
// Added '$(this)' as 'PWBFilterByBrand' argument $('.pwb-apply-filter').on('click', function () { PWBFilterByBrand($(this)); }); $('.pwb-filter-products.pwb-hide-submit-btn input').on('change', function () { PWBFilterByBrand($(this)); });
- The topic ‘Problem with multiple “Filter by Brand” widgets in the same page’ is closed to new replies.