I’m trying to translate the shipping section in my product description based on country and locale.
I already figured out how I can check for the country (localization.country.iso_code) and locale (request.locale.iso_code), but now I’m having issues targeting the part of my product description regarding shipping.
In main-product.liquid I have this part which is interesting to me:
{%- form 'product', product, class: 'ProductForm' -%}
{%- render 'product-data', product: product -%}
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when '@app' -%}
{%- render block -%}
{%- when 'product_meta' -%}
{%- render 'product-meta', form: form, block: block, product: product -%}
{%- when 'description' -%}
{%- if product.description != blank -%}
{{- product.description | replace: 'data-section-type', 'data-section-type-placeholder' -}}
My idea was to check for language and locale there, but I’m having issues targeting shipping, since the generated code for product.description looks like this:
Product Number One
Produt Number One Info
Dimensions...
Volume...
##### Fabrics...
##### SHIPPING
Shipping info
How can I set up my liquid code to achieve the the following but have only the shipping info change:
{%- if request.locale.iso_code == 'en' -%}
{%- if localization.country.iso_code == 'US' -%}
Product Number One
Produt Number One Info
Dimensions...
Volume...
##### Fabrics...
##### SHIPPING
US Shipping info
{%- elsif localization.country.iso_code == 'JP' -%}
...
This will change the English translation only for Product Number One, for US market only. I would have to do it for each product, for each country and for each locale.
Is there a way to select only the shipping section in product.description?
Ideally my could would look like this:
{%- when 'description' -%}
{%- if product.description != blank -%}
{%- if request.locale.iso_code == 'en' -%}
{%- if localization.country.iso_code == 'US' -%}
##### Shipping
Custom US shipping info.
{%- elsif -%}
{{- product.description | replace: 'data-section-type', 'data-section-type-placeholder' -}}