Hello,
I wanted to check the possibility to create a new sorting method to sort products of current collection by the stock availability.
In example, the customer could sort collection page by product availability DESC.
I have search around the Web to find some starting point codes but it looks like nothing has really been done without a paid App or some sort of third party script.
- https://community.shopify.com/c/shopify-design/sorting-products-in-a-collection-as-per-inventory-quantity/m-p/226222 No reply
- https://github.com/freakdesign/Shopify-code-snippets/blob/master/Sort%20Shopify%20collection%20by%20inventory%20count/sort-shopify-collection-products-by-inventory.liquid A github post that manipulate products in a new Array but looks difficult to integration in the current website
I am checking in the collection.sort_options (https://shopify.dev/api/liquid/objects/collection#collection-sort_options) object to see if I can add something.
Writing this tread as a starting point and to post my researches or code if I came up with something nice!
If you have hints or documentation to read, feel free to share.