Solved

Custom Liquid Variables Inside Templates?

Dawid_Dahl
Tourist
6 0 1

Hello, everyone!

 

Is it possible to get your own variables inside of liquid templates using apps? For instance if I create some kind of object in my app database, would it be possible to have this data available as a {{ placeholder variable }} in .liquid template files? Just like one would access {{ product.price_min }} or such?

 

Would be so grateful for an answer to this.

 

The more thorough explanation, if anyone has time to read it:

 

( My usecase is this: I would like to build an app for my client which lets users choose between various Pickup Spots. These Pickup Spots should be added in the Admin in my app, and then on the frontend in the template users of the app should be able to select their pickup spot that is close to their location.

 

First I thought about just keeping the data in the browser using local storage or whatever, but then I realized that I need to output the data they selected in the confirmation mail template -> "Hello, your order is ready for pickup  at {{ pickup-spot.location }}", if you know what I mean?

 

Is this even possible with Shopify somehow? I would be so grateful for any help. Thank you so much. )

Accepted Solution (1)

PaulNewton
Shopify Partner
6323 578 1341

This is an accepted solution.

Use metafields.

Code is either added to the rendered output either directly in template files, or as as custom-liquid blocks|sections, or even as app-blocks.

For frontend rendering use scripttags, sections rendering api, or app-proxies.

If you use metafields for frontend liquid templates the app , or the merchant , will still need to add that code to reference the variable.

https://shopify.dev/apps/metafields

 

I highly suggest you spend a week going over the dev docs for apps and themes to understand the integration methods, there's a lot of subchoices here

https://shopify.dev/ 

https://shopify.dev/apps/online-store/theme-app-extensions 

https://shopify.dev/apps/online-store/other-integration-methods 

 

'adding data to store|storefront''with app' and other word variations on that problem is the search phrase as there's a lot of subchoices depending on what your doing

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


View solution in original post

Replies 2 (2)

PaulNewton
Shopify Partner
6323 578 1341

This is an accepted solution.

Use metafields.

Code is either added to the rendered output either directly in template files, or as as custom-liquid blocks|sections, or even as app-blocks.

For frontend rendering use scripttags, sections rendering api, or app-proxies.

If you use metafields for frontend liquid templates the app , or the merchant , will still need to add that code to reference the variable.

https://shopify.dev/apps/metafields

 

I highly suggest you spend a week going over the dev docs for apps and themes to understand the integration methods, there's a lot of subchoices here

https://shopify.dev/ 

https://shopify.dev/apps/online-store/theme-app-extensions 

https://shopify.dev/apps/online-store/other-integration-methods 

 

'adding data to store|storefront''with app' and other word variations on that problem is the search phrase as there's a lot of subchoices depending on what your doing

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


Dawid_Dahl
Tourist
6 0 1

Thank you so much Paul, I will look into this right away! 😃