Ecommerce Shopify WordPress Discussion

How do I add a custom discount filter to Shopify using the Palo Alto theme?

I am using Alto version 4.6.3, I added a custom discount filter like 10% 20% 30%... I tried using JavaScript to filter the products... But I have faced an issue: Product not showing After clicking, the filter works fine but is not visible. I can click but the product is not visible. But after scrolling all the products it is visible and works well. First, I tried integrating the discount filter inside the default filter. But after clicking on other filters the javascript of the discount filter doesn't work... Screenshot of invisible product collection.liquid <label for="discount-filter">Discount</label> <div class="discount-list" id="discount-list"> <div class="discount-item"> <div class="discount-circle" data-discount="">All</div> </div> <div class="discount-item"> <div class="discount-circle" data-discount="10">10%</div> </div> <div class="discount-item"> <div class="discount-circle" data-discount="20">20%</div> </div> </div> theme.js $(document).ready(function () { $('.discount-circle').click(function () { $('.discount-circle').removeClass('selected'); $(this).addClass('selected'); const selectedDiscount = $(this).data('discount'); filterDiscounts(selectedDiscount); }); const selectedDiscount = $('.discount-circle.selected').data('discount'); filterDiscounts(selectedDiscount); }); function filterDiscounts(selectedDiscount) { $('.product-grid-item').each(function () { var productDiscount = parseInt($(this).data('discount')); if (selectedDiscount === '') { $(this).show(); } else { var lowerBound = selectedDiscount; var upperBound = selectedDiscount + 9; if (productDiscount >= lowerBound && productDiscount <= upperBound) { $(this).show(); } else { $(this).hide(); } } }); } product-grid-item.liquid {% assign price = product.price %} {% assign price_compare = product.compare_at_price %} {% assign price_difference = price_compare | minus: price %} {% assign percent_off = price_difference | times: 1.00 | divided_by: price_compare | times: 100 %} {% assign discount = percent_off | floor | append: '%'%} <span class="product-discount-percentage"> {{ discount }} </span\> <div class="product-grid-item" data-discount="{{ discount }}"> // products render html </div>
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.