• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Sort products by price using Liquid and {tag_productlist}

Community Beginner ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Hi guys,

I am trying to have a "Sort by price (high to low)" and "Sort by price (low to high)" buttons on my website and having difficulty outputting the correct liquid code to do this. Can someone else?

By default, the page will display the products by name, and I was thinking of adding buttons which add to the URL "?sort=price-high-to-low" which I can then output the data using:

{% for items in products.item %}

{% if globals.get.sort = 'price-high-to-low' %}

<li>{{item.name}}</li>

{% endif %}

{% endfor %}

How do I then sort the outputted data by price? and price descending?

I am currently using:
{tag_productlist,1,,100,,true,collection="products" template=""}

{tag_productlist,1,,100,price,true,collection="products" template=""} -> outputs exactly what I want, but how to get this working with Liquid?

Appreciate the help!

TOPICS
eCommerce

Views

260

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines