sort by price not working as intended

sort by price not working as intended

Atlas_0ne
New Member
7 0 0

Im using Trade theme

let me start with the thing that started all of this, I had multiple variants on a item and it was showing the cheapest option instead of the main price when viewing items so i found a guide and fixxed that issue which was to do

Online Store > Themes > Edit code > search for "price.liquid"  
then proceed to find this line

if target == product and product.price_varies assign money_price = 'products.product.price.from_price_html't: price: money_price endif

then change

t: price: money_price

to

t: price: money_price_max

 

but now when i sort by highest price in the product grid its going off the cheapest variant instead of the actual so the top rows there are $90 products displayed but if you scroll to row 3 theres randomly $200 prices listest

Replies 4 (4)

ShreyaRevize
Shopify Partner
64 7 11

Hey @Atlas_0ne 

Based on your issue, it sounds like you've fixed the display of prices in the product grid, but now the sorting functionality in your collection grid is not working correctly. This is because your theme is still using the default price for sorting rather than the maximum price.
Here's how to fix the sorting issue:

  • Go to your Shopify admin
  • Navigate to Online Store > Themes
  • Click "Edit code" on your Trade theme
    Look for the file that handles collection sorting. This is typically in one of these files:

collection.liquid
collection-template.liquid
Or possibly in a file inside the snippets folder related to sorting or collection grids


Search for code related to sorting or price sorting. Look for something like:

{% assign sorted_products = collection.products | sort: 'price' %}

or

{% when 'price-descending' %}
{% assign sorted_products = collection.products | sort: 'price' | reverse %}

Change the sort parameter from 'price' to 'price_max' like this:

{% when 'price-descending' %}
{% assign sorted_products = collection.products | sort: 'price_max' | reverse %}

Make the same change for the 'price-ascending' sort option if it exists.
Save your changes.

This modification should make your collection grid sort by the maximum variant price instead of the default (minimum) price, which will match the prices you're now displaying on your product grid.

Feel free to give it a try on your end, and if you need any help, just send us your collaborator code via DM or email. We’ll gladly make the necessary changes for you for free. Looking forward to assisting you! 😊

Cheers,
Shreya

Helping for free: hello@untechnickle.com
Get Revize for Free | Let your shoppers edit orders post-purchase | Get Zero Support Tickets | #1 Order Editing + Upsell App
Atlas_0ne
New Member
7 0 0

i do not seem to have any of the .liquid files the only thing i can find refencing sorting is in main-collection-product-grid.liquid and im not seeing anything similar to {% assign sorted_products = collection.products | sort: 'price' %} 

Atlas_0ne_0-1742754040454.png

 

Atlas_0ne
New Member
7 0 0

Atlas_0ne_1-1742754299002.png

 

ShreyaRevize
Shopify Partner
64 7 11

Will it be fine if I can have a look at your theme code and fix it for free? Would be willing to DM or email your collaborators code? 

Helping for free: hello@untechnickle.com
Get Revize for Free | Let your shoppers edit orders post-purchase | Get Zero Support Tickets | #1 Order Editing + Upsell App