Add "Remote Storage" insted of "In stock" or "Out of stock"

FTENK
Visitor
3 0 0

Hello,

I would like to add "Remote Storage" insted of "In stock" or "Out of stock" on my product page. I can't just change that in "default theme content" because that would obveusly change every product. I would like to be able to tick a box to apply for exactly the items that are in remote storage.
Kind of like you can under the Inventory section on the product edit page. "Track quantity" and "Continue selling when out of stock". Under those boxes I think it would be cool to have an "Remote storage" box.

Does someone here know how to get the coding right? Thanks

Replies 3 (3)

Liam
Shopify Staff
2731 298 769

Hi FTENK,

 

If this is pattern is only for one product, you could create an alternative JSON template that is only applied to the product and create a matching new alternative `main-product.liquid` section file where you're replacing the out of stock message with your custom one. Then this section file would be included in the alternative product template file, and you could assign this product on the admin to use this template.

 

This might be the easiest approach, if it's just one product that would follow this pattern, but it also could be worth looking into using metafields too if there's plans on more?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

FTENK
Visitor
3 0 0

Yes, that would be great if it only was a few products, like you said, but this applies to several products, 100+.


How can I use metafields to help me achieve this?

Thanks!

Liam
Shopify Staff
2731 298 769

Would you be able to apply product tags to the products which should say "Remote storage"? If so you could keep the same product section and not use alt templates but set up some logic with Liquid so that a different message is displayed for out of stock. 

 

A model for this could be:

 

 

{% if product.available == false %}
  {% if product.tags contains 'special' %}
    <p>Remote Storage</p>
  {% else %}
    <p>Out of stock</p>
  {% endif %}
{% endif %}

 

Would this approach work for you?

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog