Accessing Unavailable Products with Liquid

arnedirlelwy
Tourist
4 0 1

Hello,

I am trying to figure out how to have a product that is unavailable to customers, but has inventory, that I can access in product_template.liquid to check how many are left.

all_products['handle'] won't work if the product is unavailable but making the product available makes it so the customer has access to that product.

 

Does anyone know of a way to access unavailable products through code, or a way to hide a product from the customer when it is marked available?

-Andy

Replies 3 (3)

Niraj_singh
Shopify Partner
232 39 47

we can edit the product template file by liquid with help of adding tags to product and make that product available or not available based on tag.
I can help you on this you can have a look on my proven work record at https://upwork.com/fl/niraj1420

banned

Propero
Shopify Partner
896 101 159

@arnedirlelwy 

Hi Andy,

You can simple create an alternate product template which basically doesn't; do anything and assign all such products, you want to make unavailable to this template.

Please see the documentation on how to create alternate template here, if you already do not know

https://shopify.dev/tutorials/customize-theme-create-alternate-templates

- Was my reply helpful? Click Like or Click Accept as Solution
To hire: email us at shopify@propero.in
checkout our app https://apps.shopify.com/picamaze
arnedirlelwy
Tourist
4 0 1

If I am following correctly, that just changes the way the product page looks but the product still shows up on my Products page. Am i missing a step? 

 

For context:

What I am trying to achieve is a backorder system. So my actual product, when a variant inventory reaches 0, it checks a backorder inventory (the hidden version of the product), and then allows the customer to backorder the item. This way I can limit the amount of total backorders without limiting quantity for each variant. Basically a global pool of backstock with a limitation on total ordered.