How can I change 'add to cart' to 'pre-order' on a product listing?

Hi There, can anyone sense check this for me please, pretty sure it works without side issues…? Or is there a better way…? Not a code expert…

-changes the “add to cart” to “pre-order” if the tag “pre-order” is added to the product listing

-changes back to “sold out” when inventory hits zero (so you can add the inventory quanity due in)

-dawn theme / main.product.liquid / replace span after line 399

{%- if product.tags contains 'pre-order' and product.selected_or_first_available_variant.available -%} pre-order {%- else -%} {%- if product.selected_or_first_available_variant.available -%} {{ 'products.product.add_to_cart' | t }} {%- else -%} {{ 'products.product.sold_out' | t }} {%- endif -%} {%- endif -%}

@NH
What issues are occuring in this code?

none that I can see so far, just looking for some expert approval or recommendation before going live - always get a bit nervous mucking around with “add to cart” code :slightly_smiling_face:

@NH
of course, try this it will work.

thx, seems to work, my confusion come from not really understanding if it needed a “for” loop:

{% for tag in product_card_product.tags %}

just trying to get a better understanding of liquid :slightly_smiling_face:

I would also like to do this… Which code exactly did you replace, please?

Below is what I have.

Many thanks…

looks to be the span at line 413 for you…

Great, thanks.