Storing Liquid Syntax in metafield - shopify

I'm trying to work out a way to store liquid syntax in a shopify collection metafield. It can store fine in multi line text, but when i call that metafield in the template editor, it renders as text and wont actually process the liquid code. Even if i call it in a blank section as text, it just dumps the content of the metafield and wont render the liquid.
Hope that makes sense! Thanks in advnace and please let me know if i havent described it clear enough!
What am i missing here?
Tried calling the content of a metafield in shopify, of whicch the content is liquid code. That code wont render.

Related

Outputting Shopify product metafields as HTML

I'm working on a custom code block for the Tapcart app version of my e-commerce site on Shopify. They have the ability to add HTML, CSS and/or JS in a custom code block.
However, I cannot get the html to output the custom fragrance notes (my custom metafield) for the product. Matter of fact, I can't get anything to output- it's just blank.
Thoughts? Appreciate your help!
{{product.metafields.custom.fragrance_notes}}
I tried {{product.metafields.custom.fragrance_notes}} expecting it to output the plain text multi-line of each individual product's fragrance notes (which I have as a custom metafield for each product) but instead nothing displays at all.
When asking for metafield data you can often meet with success by asking for the value stored at that key.
{{product.metafields.custom.fragrance_notes.value}}
Since the namespace is custom, the key is fragrence_notes and what you want to use or display is the value. So it is a key:value thing.
Of course, if your metafield is empty, you won't see anything no matter what.

Render as HTML the line_item.properties data who has HTML values in it on Shopify Admin Orders

Hi so I'm wondering If it is possible to render these custom line_items.properties value as HTML in my orders? in shopify, as of now it appears like this when the order is viewed. The object value is not rendering those HTML tags.
I'm using the format below to submit the order onto my Shopify account and I was kinda hoping it will display a View Image link.
properties: {
sample_image: "View Image"
}
I solved it, so what I didn't know by then is that shopify already handle this kind of data. If the lineItem.properties has a value of URL or any kind of link, shopify will automatically add an anchor tag to it.
So instead of adding an anchor tag to the lineItem.properties, just use the ordinary link/url and that'll do the job.

How to Include Snippet from App in Shopify Liquid

What I am trying to do:
I am trying to create an app that inserts content to the merchant's product page.
It appears that an app extension into the merchant's Online Store is the most effective way to do this (see https://shopify.dev/docs/app-extensions/extension-areas#online-store/).
In order to display the content, I am trying to use either a snippet or a section. However, I cannot get either of them to work properly.
I have taken these steps for the snippet:
I have enabled Online store as an extension area within my app (see https://shopify.dev/tutorials/add-a-new-app-extension)
With the Online store extension enabled, I have created a new snippet and a new section with very basic liquid code <h2>{{ product.title }}</h2>
I have enabled my app into a test store on my Shopify Partner account
I have added the {% render 'shopify://apps/etc... %} code into the correct position within the product page
Problem:
The content is not rendered
I have even tried this with the Sections Compatible version of the Debut template (see https://shopify.dev/tutorials/develop-theme-get-started-with-online-store-design-experience). Still nothing.
Is someone able to point me in the right direction here?

Accessing settings json file in shopify from JS or product liquid page

I check this and it wasn't the same as my question:
Editing JSON data from within a shopify liquid page
Currently I have a file settings_data.json in my theme. This file has a specific field called "product_form_style" there is a specific field I need to edit here from one product template titled: product_custom_liquid
According to some scarce resource I read this would work:
{% settings.product_form_style == 'my value' %}
This however gives an error: "Liquid syntax error: Unknown tag 'settings'"
The official documentation says I can access it with ajax or jquery from js however it doesn't give any examples. It only says it can be done but I have no idea how.
The basic idea is if product template is 'product_custom' then change settings product_form_style == true.
Obviously the above is not correct syntax. Just an example.
You can't modify the settings_data.json from the front-end without using an APP.
If you could modify it without any authentication this would have been a huge security issue and anyone could modify it.
settings_data.json is modified only when you save something in your Customize panel. For any other way you will need a Private app or some App to do so.
In addition you can't modify files in any way from the liquid code as well. The liquid template language only outputs data, it can't modify that data without the use of some kind of an APP.

Passing Global Variables

I'm trying to figure out how I can pass Shopify Global Variable, such as {{ discount_code }} for example, as a Custom Variable/Dimension into the "Additional Scripts" textarea.
We really just want to know if we can get the discount_code parameter in the thankyou page by giving the proper variable syntax. Thanks.
See this article on the Shopify wiki on how to customise your thank you page.
It says:
In the Additional Content & Scripts box, you can use:
HTML — anything goes here, you can use script, style, iframe and object elements, any valid HTML5 element is fair game.
Liquid — you're somewhat limited to what Liquid you can use, but you have access to the essentials, that is, the order and the shop variables.
So, you should be able to access the discounts property from the order variable.