Display Estimated Delivery times on my product page

Hello Everybody!
New to Shopify and liquid code.
I would like to add a custom Liquid section on my product page to display my estimated delivery times.
I would like it to show based on my own stock but also my suppliers stock (variant-metafield).
From looking around many forums I been trying to make some code without a lot of luck.

{% if product.variants.first.inventory_management == "shopify" %} {% comment %} More than 5 in stock {% endcomment %} {% if product.variants.first.inventory_quantity > 5 %} På lager – 1-2 dage leveringstid. {% comment %} 1 or less than 1 {% endcomment %} {% elsif product.variants.first.inventory_quantity <= 1 and product.variants.first.metafields.custom.leverand_r_lager == "Fjernlager" %} {% comment %} More than 10 in stock {% endcomment %} {% if product.variants.first.inventory_quantity > 10 %} In Stock - Delivery time: 4-5 days. {% comment %} Less than 10 in stock {% endcomment %} {% elsif product.variants.first.inventory_quantity <= 10 %} Soldout - Ask for delivery time {% endif %}

{% endif %}

{% endif %}

Does anybody have any advice or suggestions to make it work? Would be much appriciated

For metafields use .value property , super annoying but required for most cases.

Then simply the problem.

First un-nest the logic into smaller problems, you’ve got less than or equal to 1 then trying to get greater than 10 which will never happen.

Then format your code; on the forums use the ‘insert/edit code sample’ button beyond the three vertical dots.

Output values directly to validate assumptions of what data there is and how it behaves.

Then test against known variant stocks to verify each piece of individual logic.

i.e.

{{- product.variants.first.metafields.custom.leverand_r_lager.value -}}

{{- product.variants.first.inventory_quantity -}}