Java Script newb question

New Member
3 0 0



I want to make create a script that affects all my product pages.  Basically I want it to say in stock, and when less than zero, it should say out of stock an expected date.  Where do I place the script, in what particular liquid file and where in that file?



Ken Christensen


Shopify Partner
38 7 7

Hi Travis_Morgan,

It depends on wich theme your are using. Usually the file is called product-template.liquid or product-info.liquid. Just try some files and use the search function to find stock. Your Liquid code would be something like this:

{%- assign selected_variant = product.selected_or_first_available_variant -%}
{%- if selected_variant.available -%}
{%- if selected_variant.inventory_management and selected_variant.inventory_quantity > 0
<p>Product is in stock</p>
{%- else-%}
<p>Product is not in stock</p>
{%- if selected_variant.incoming and selected_variant.next_incoming_date -%}
Product available on {{ selected_variant.next_incoming_date | date: "%d %B %Y" }}
{%- endif -%}
{%- endif -%}
{%- endif -%}
1 Like