Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Get default (untranslated) value of product field in liquid

Get default (untranslated) value of product field in liquid

AlexF_
Shopify Partner
17 0 21

Hi,

 

I need to get the untranslated value of the product type in the liquid code. Before translating our store in other languages, we were using the product type as a condition of some of the features some of our product pages would display, which was working fine and would prevent us from relying too much on tags and metafields, which would clutter the interface at some point.

Is there a way to get the original, default value of a product field ? In the API, translations are their very own things, and while I get that in the theme you want a translated content by default, it seems very unpractical to me that we don't have a filter or another mean to get the base value.

Replies 3 (3)

kazi
Shopify Partner
724 100 125

I had to do a tricky way to get store default value of product through javascript fetching .json of store base language

 

{% assign full_url = request.origin | append: request.path | append: '.json?country=CH' %}

 

<script>

const url = '{{ full_url }}';
async function load() {

obj = await (await fetch(url)).json();
const price = obj.product.variants[0].price;

console.log(data);

}
}

 

load();

</script>

▶️ If you need more help with your Shopify store
Speed Optimization | Theme Customization ? ☎️ WhatsApp ✉️Email Skype: kof.bd

AlexF_
Shopify Partner
17 0 21

Hi Kazi,

 

Thank you for your answer. It could be a nice solution when you have a JS-first storefront, but ours is mainly liquid-generated and we want to keep it this way for now. Fetching the product informations one more time in the browser should not have to be done just to be able to access base values...

kazi
Shopify Partner
724 100 125

A filter option is needed to get store default product values 

▶️ If you need more help with your Shopify store
Speed Optimization | Theme Customization ? ☎️ WhatsApp ✉️Email Skype: kof.bd