What this article will cover

  1. Variants in Shopify & default ordering
  2. Why lowest price variant at top ?
  3. Checking for a products variants
  4. Re-positioning with API

Pre requisite : You will require Shopify general knowledge, which includes knowledge about shopify store, products and variants. Variants can be simply understood as a product available in different types/styles.

In shopify and other eCommerce platform, a product in various forms or types is general thing. For eg. a PC Monitor in a store might come in various color or sizes. And with those variations in those attributes different pricing can be set. Below is the screenshot of a variant of a product.


These variants ordering is random and the one appearing at top appears as the product price on product listing page and product detail page. The business need i encountered was to show the lowest price on listing price.

Convention : I have used this Shopify private app skeleton https://github.com/phpish/shopify_private_app-skeleton.git for API requests. This has managed things better than we do manually.

So i wrote a script that would check figure out all the products which don’t have lowest price variant at top. With the script below i could check all the products whose default variant price isn’t lowest among other.

The logic to update the lowest price variant is, the first lowest price variant position to set to position 1. I first tried updating the position of the first lowest price variant to position 1. Hoping that other variants position would adjust as accordingly. But doing that it ended up having two variants having position 1. i.e. other variants position didn’t adjust as accordingly, So now i updated other variants position manually.

Now this is the result i obtained. the lowest first price variant position appeared at top.

after update



And now for reconfirmation among all the products i ran the script that would check if any product don’t have a lowest variant at position 1, then i found it to be null.

Suman K.C

eCommerce Developer, writes about stuff related to eCommerce development. Currently based in Kathamandu, loves reading about startups & new technology, introvert nature, fond of traveling & playing volleyball.

More Posts - Website

Follow Me:
LinkedInGoogle Plus