Use part of the tag as a text in product section

Hi,

Currently, i have a tag (showprice_) that whenever i use it along with another tag (PreOrder), it shows a text on my product page.

The way it works is when I use lets say “showprice_1000” it will show a text under the product price which is “Pre-Order partial payment: dhs 1,000.00”

so basically whatever is written after “showprice_” will be visible as a text.

(“showprice_1000” will be replaced with “1000” as it will remove the “showprice_”)

Now i want to create something similar and much simpler that whenever i use lets say “date_ETA April 2022” it will show a text under the product price as “ETA April 2022”

If someone could help me out on this, it would be really appreciated!

Below you can see the code for the product-grid-item.liquid

{% if product.price != 0 %}

{%- unless grid_item_width -%}
{%- assign grid_item_width = ‘medium-up–one-quarter small–one-half’ -%}
{%- endunless -%}

{%- assign on_sale = false -%}
{%- if product.compare_at_price > product.price -%}
{%- assign on_sale = true -%}
{%- endif -%}

{%- assign sold_out = true -%}
{%- if product.available -%}
{%- assign sold_out = false -%}
{%- endif -%}

{%- assign product_tags = product.tags | join: ‘,’ -%}
{%- assign has_custom_label = false -%}
{%- for tag in product.tags -%}
{% assign tagLower = tag | downcase %}
{%- if tagLower == ‘instant delivery’ -%}
{%- assign has_custom_label = true -%}
{%- assign custom_label = tagLower -%}
{%- elsif tag contains ‘label’ %}
{%- assign tag_starts_with = tag | slice: 0 -%}
{%- if tag_starts_with == ‘_’ -%}
{%- assign has_custom_label = true -%}
{%- assign custom_label = tag | replace: ‘label’, ‘’ -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}

{%- unless hide_prod_data -%}
{%- if has_custom_label -%}
{% assign customLabelDowncase = custom_label | downcase %}
{% if customLabelDowncase == ‘best seller’ %}

Best seller
{% elsif customLabelDowncase == 'instant delivery' %}
Instant delivery
{% elsif customLabelDowncase == 'just arrived' %}
Just arrived
{% elsif customLabelDowncase == 'new arrival' %}
New arrival
{% else %}
{{ custom_label }}
{% endif %} {%- else -%} {% assign check_new = false %} {% assign preorder = false %} {% assign exclusive = false %} {% assign limitededition = false %} {% assign tltexclusive = false %} {% for tag in product.tags %} {% assign tag_downcase = tag | downcase %} {% if tag_downcase == "preorder" %} {% assign preorder = true %} {% elsif tag_downcase == "new" and tag_downcase == false %} {% assign check_new = true %} {% endif %}

{% if tag_downcase contains “showprice_” %}
{% capture showprice %}{{ tag | downcase | replace: “showprice_” | money }}{% endcapture %}
{% endif %}
{% if tag_downcase contains “exclusive” %}
{% assign exclusive = true %}
{% endif %}
{% if tag_downcase contains “limitededition” %}
{% assign limitededition = true %}
{% endif %}
{% if tag_downcase contains “tltexclusive” %}
{% assign tltexclusive = true %}
{% endif %}

{% endfor %}

{%- if preorder -%}

Preorder
{%- elsif sold_out -%}
{{ 'products.product.sold_out' | t }}
{%- elsif on_sale and settings.product_save_amount_label -%}
-{{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round }}%
{%- elsif check_new -%}
{{ 'products.product.new' | t }}
{%- endif -%}

{% if limitededition %}

Limited Edition
{% elsif tltexclusive %}
Exclusive
{%- elsif exclusive -%}
{{ 'products.product.exclusive' | t }}
{%- endif -%}

{%- endif -%}
{%- endunless -%}

{%- assign fixed_aspect_ratio = false -%}
{%- unless settings.product_grid_image_size == ‘natural’ -%}
{%- assign fixed_aspect_ratio = true -%}
{%- endunless -%}

{%- assign preview_image = product.featured_media.preview_image -%}
{%- assign img_url = preview_image | img_url: ‘1x1’ | replace: ‘1x1.', '{width}x.’ -%}

{%- if quick_view_enable or settings.quick_shop_enable and sold_out == false -%}
{{ settings.quick_shop_text }}
{%- endif -%} {%- if fixed_aspect_ratio -%}
{%- else -%}
{{ preview_image.alt | escape }} {{ preview_image.alt | escape }}
{%- endif -%}

{% unless hide_prod_data %}

{%- unless sold_out -%}
{%- if settings.product_hover_image and product.images.size > 1 -%}
{%- for media in product.media offset: 1 limit: 1 -%}
{%- assign second_image = media.preview_image -%}
{%- endfor -%}

{%- endif -%} {%- endunless -%}

{%- if settings.collection_color_swatches -%}
{%- assign swatch_trigger = ‘products.general.color_swatch_trigger’ | t | downcase-%}
{%- for option in product.options_with_values -%}
{%- assign option_name = option.name | downcase -%}
{%- assign is_color = false -%}
{% if option_name contains swatch_trigger %}
{% assign is_color = true %}
{%- elsif swatch_trigger == ‘color’ and option_name contains ‘colour’ -%}
{% assign is_color = true %}
{% endif %}
{%- if is_color -%}
{%- assign option_index = forloop.index0 -%}
{%- assign values = ‘’ -%}
{%- for variant in product.variants -%}
{%- assign value = variant.options[option_index] %}
{%- unless values contains value -%}
{%- assign values = values | join: ‘,’ %}
{%- assign values = values | append: ‘,’ | append: value %}
{%- assign values = values | split: ‘,’ %}

{%- if variant.image -%}

{%- endif -%} {%- endunless -%} {%- endfor -%} {%- endif -%} {%- endfor -%} {%- endif -%}

{% endunless %}

{% if show_rate_numbers %}
{{ rate_numbers }}
{% endif %}

{% unless hide_prod_data %}

{%- if settings.collection_color_swatches -%}
{%- assign swatch_trigger = ‘products.general.color_swatch_trigger’ | t | downcase-%}
{%- assign swatch_file_extension = ‘png’ -%}
{%- assign color_count = 0 -%}

{%- for option in product.options_with_values -%}
{%- assign option_name = option.name | downcase -%}
{%- assign is_color = false -%}
{% if option_name contains swatch_trigger %}
{% assign is_color = true %}
{%- elsif swatch_trigger == ‘color’ and option_name contains ‘colour’ -%}
{% assign is_color = true %}
{% endif %}
{%- if is_color -%}
{%- assign option_index = forloop.index0 -%}
{%- assign values = ‘’ -%}

{%- for variant in product.variants -%} {%- assign value = variant.options[option_index] %} {%- unless values contains value -%} {%- assign values = values | join: ',' %} {%- assign values = values | append: ',' | append: value %} {%- assign values = values | split: ',' %}

{%- assign color_swatch_fallback = value | split: ’ ’ | last | handle -%}
{%- assign color_count = color_count | plus: 1 -%}

<a
href=“{{ variant.url | within: collection }}”
class=“color-swatch color-swatch–small color-swatch–{{ value | handle }} color-swatch–{{product.id}}_{{ value | handle }}{% if variant.image %} color-swatch–with-image{% endif %}”
{% if variant.image %}
data-variant-id=“{{ variant.id }}”
data-variant-image=“{{ variant.image | img_url: ‘400x’ }}”
{% endif %}
style=“background-image: url({{ color_image }}); background-color: {{ color_swatch_fallback }};”>

{%- endunless -%}
{%- endfor -%}

{%- if color_count < 2 -%} {% style %} .grid-product__colors--{{ product.id }} { display: none; } {% endstyle %} {%- endif -%} {%- endif -%} {%- endfor -%} {%- endif -%}
{{ product.title }}

{%- if settings.vendor_enable -%}

{{ product.vendor }}
{%- endif -%}
{% if preorder and showprice %} {{showprice}}
{%- if on_sale -%} {{ 'products.general.regular_price' | t }} {{ product.compare_at_price | money }} {{ 'products.general.sale_price' | t }}

{%- if settings.product_save_amount -%}
{%- if settings.product_save_type == ‘dollar’ -%}
{% capture saved_amount %}{{ product.compare_at_price | minus: product.price | money }}{% endcapture %}
{%- else -%}
{% capture saved_amount %}{{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round }}%{% endcapture %}
{%- endif -%}

{{ ‘products.general.save_html’ | t: saved_amount: saved_amount }}

{%- endif -%}
{%- endif -%}

{% endif %}

{% if preorder == false %}
{%- if on_sale -%}
{{ ‘products.general.regular_price’ | t }}
{{ product.compare_at_price | money }}
{{ ‘products.general.sale_price’ | t }}
{%- endif -%}
{% endif %}
{%- if product.price_varies -%}
{%- assign price = product.price_min | money -%}
{{ ‘products.general.from_text_html’ | t: price: price }}
{%- else -%}
{{ product.price | money }}
{%- endif -%}

{% if preorder == false %}
{%- if on_sale -%}
{%- if settings.product_save_amount -%}
{%- if settings.product_save_type == ‘dollar’ -%}
{% capture saved_amount %}{{ product.compare_at_price | minus: product.price | money }}{% endcapture %}
{%- else -%}
{% capture saved_amount %}{{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round }}%{% endcapture %}
{%- endif -%}

{{ ‘products.general.save_html’ | t: saved_amount: saved_amount }}

{%- endif -%}
{%- endif -%}
{% endif %}

{%- assign product_variant = product.selected_or_first_available_variant -%}
{%- if product_variant.unit_price_measurement -%}

{%- capture unit_price_base_unit -%} {%- if product_variant.unit_price_measurement -%} {%- if product_variant.unit_price_measurement.reference_value != 1 -%} {{ product_variant.unit_price_measurement.reference_value }} {%- endif -%} {{ product_variant.unit_price_measurement.reference_unit }} {%- endif -%} {%- endcapture -%}

{{ product_variant.unit_price | money }}/{{ unit_price_base_unit }}

{%- endif -%}
{% render 'judgeme_widgets', widget_type: 'judgeme_preview_badge', jm_style: '', concierge_install: false, product: product %} {%- if settings.enable_product_reviews -%} {%- endif -%}

{% endunless %}

{% unless hide_prod_data %}

{% assign color_arr = product.metafields.product.colors | newline_to_br | replace:'
', 'll_ll' | replace:'
', 'll_ll' | replace:'
', 'll_ll'| replace:' :::', ':::'| replace:'::: ', ':::' %} {% assign color_arr = color_arr | split:'ll_ll' %} {%- for color_arr_items in color_arr -%} {% assign color_arr_item = color_arr_items | split:':::' %} {%- if color_arr_item[1] contains "|" -%} {% assign gradient = color_arr_item[1] | split:'|' %} .color-swatch--{{product.id }}_{{color_arr_item[0] | handle}} { background: linear-gradient(to left, {{gradient[1]}}, {{gradient[1]}} 50%, {{gradient[0]}} 50%, {{gradient[0]}} 100%); } {% assign text_color = gradient[0] %} {%- else -%} .color-swatch--{{product.id }}_{{color_arr_item[0] | handle}} {background-color:{{color_arr_item[1]}} !important;} {%- endif -%} {%- endfor -%} {% assign image_arr = product.metafields.product.images | newline_to_br | replace:'
', 'll_ll' | replace:'
', 'll_ll' | replace:'
', 'll_ll'| replace:' :::', ':::'| replace:'::: ', ':::' %} {% assign image_arr = image_arr | split:'ll_ll' %} {%- for image_arr_items in image_arr -%} {% assign image_arr_item = image_arr_items | split:':::' %} {%- assign variant_metafields_variant_image = image_arr_item[1] | replace: '.jpg', '_400x.jpg' | replace: '.JPG', '_400x.JPG' | replace: '.jpeg', '_400x.jpeg' | replace: '.JPEG', '_400x.JPEG' | replace: '.png', '_400x.png' | replace: '.PNG', '_400x.PNG' | replace: '.gif', '_400x.gif' | replace: '.GIF', '_400x.GIF' -%} .color-swatch--{{product.id }}_{{image_arr_item[0] | handle}} {background-image:url({{ variant_metafields_variant_image }}) !important;} {%- endfor -%}

{% endunless %}

{% endif %}

1 Like

@RamtinDB

can you please share store url

Hi Ketan,

Please find the URL below:

https://littlethingsme.com/products/ikigai-izuku-midoriya

This has the partial payment in it.

1 Like

@RamtinDB

yes i can see this