Marketing | Creative | Strategy

Your faithful partner in the discovery of endless digital opportunity.

Take the First Step

SHOW ME THE MONEY: How to Find the Price of the Most Expensive Item in a Shopify Store

Whether it’s for bragging rights, or you’re trying to give someone an idea of the prices of the products you sell, or you just want to know for the hell of it… sometimes it can be very useful to locate the price of the most expensive item in your Shopify store.

It seems like a simple question, however there could be some tricky pieces to this puzzles, because of the way that Shopify lists this information. So let’s start at the beginning… which if “Sound of Music” has taught us anything it’s that this... is a very good place to start.


If you’ve worked with Shopify before and have a working knowledge of the code, the first thing that might come to your mind is to initialize the variable of the maximum price(maxPrice) to a very low value, or 0. Just to set that baseline. Then, you create a for-loop, which runs through all of the products of the catalog to check if the price of the current product is higher than the maxPrice variable. If yes, then set the value of maxPrice to the current product's price. Easy enough.


Unfortunately for everyone, a for-loop in Shopify can only search through 50 products at a time, so if the online shop has more than 50 products, some values will remain not checked. Certainly an issue, considering you’re trying to find the most expensive item in the shop, not the most expensive item out of 50 items.


In order to avoid this limitation, we could use the collection “All”, a collection that contains all the products in the shop - if it was created. Now, if you haven’t created this collection this is where you create it. For this coding purpose, we sort the collection. Don’t worry if you set the order of “All” collection manually in Shopify administration, they will keep this order on the “All” collection page. The sorting we will make is just for coding purpose so this will not have any visual impact on the page.

Here’s the code that orders the products by price:

{% assign productsMax = collections['all'].products | sort: 'price' %}

Once you have the value for productsMax, you can check the name and the price of the product with the highest price using Javascript to display the result in the console using the following script:

console.log("Title: " + {{ productsMax[-1].title | json }} );
console.log("MaxPrice: " + {{ productsMax[-1].price_max | money | json }} );

Now that you have this collection set, you can also use the earlier for-loop idea as well to determine the highest price now that you are no longer limited by the 50 items in this new “All” collection.

Knowledge is power, we all know that, and knowing the most expensive item in your Shopify store will arm you next time you need to speak to the client or a customer who’s ready to drop some major cash. Know your limits low and high.

Interested in our Creative & Development services? Get in touch!


Get A Quote

Ready to take the next step? Please fill out the form below. We can't wait to hear from you!

Once submitted, a Slicedbread representative will be back in touch with you as soon as possible.

* Required Fields