Stop selling before inventory reaches zero

Hi everyone,

From my online inventory I need 500 pcs of each to give as sample to our costumers. So I want Shopify to stop selling products when the inventory reaches below 510 pc. The products have to stay visible on the webshop though.

I know that there are some changes that I can make to the liquid code, but I can’t get it to work.

Here’s what I tried: (and many variations to this)


    {%- if product.available and variant.inventory_quantity < 510 -%}    
    {%- assign sold_out = true-%}
    {% else %}
    {%- assign sold_out = false -%}
    {%- endif -%}

    
    {% if sold_out and product.type != "Uitverkocht" %}
    {{ 'products.product.sold_out' | t }}
    {% else %}
    {{  product.type }}
    {% endif %}
    

This piece of code is in product-price.liquid and product-price-listing.liquid and let’s me show two different sold out messages: ‘sold out’ and ‘temporary not available’.

The solution only needs to work for a month or so, until I get the samples shipped out.

If there’s an app that does the job, that welcome too. I only found ‘Delist’, but it removes the products from the front-end, which is not what I want.

My store is working on a debut theme, you can see it here: www.bickerykerst.nl

If you need more information to be able to help me, let me know.