Access HTTP POST data sent to Shopify page

Solved
Highlighted
Tourist
3 0 0

I have an HTTP POST that is generated by a Shopify page I created. I need to access the POST data from the liquid page. Is this possible? It seems like there should be some handle for this. It seems rather obvious, but I cannot find any documentation on this. Is it possible?

0 Likes
Highlighted
Shopify Partner
2294 116 353

This is an accepted solution.

Liquid is not a server side processing language like PHP it is a simple safe template language.

Thus self defined url parameters are not supported in liquid for themes.

 

For the various url parameters that are used by shopify, they are used to generate the data then rendered in the view.

So what you can access depends on the object like the selected variant, or the current vendor or search terms, etc

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
1 Like
Highlighted
Tourist
3 0 0

It would be helpful if there was a Liquid object with the POST data, or at least some subset of the POST data. I'll use GET for now, but there are known security issues with GET.

0 Likes
Highlighted
Shopify Partner
2294 116 353

It would be helpful if there was a Liquid object with the POST data

Again shopify is not like running a PHP or ruby server and that would be a major increase i

https://github.com/Shopify/liquid/

Such data is highly dynamic allowing access to parameters would undermine shopify's ability to scale with aggressive cache'ing for pages.

 

there are known security issues with GET

Processing dynamic fields defined by end-users is an even bigger known security issue

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
Highlighted
Tourist
3 0 0

How about some subset of data? Something like a key value pair that can be accessed through a Liquid object: customHandler=somedatahere. I have gotten the system working using AJAX and a dynamically created token over GET, but POST is the right way to do it.

0 Likes
Highlighted
Shopify Partner
2294 116 353

How about some subset of data? Something like a key value pair that can be accessed through a Liquid object

Technically the querystring itself is exposed in the content_for_header but you'd have to strip it out and that usage is not supported and the cache is involved.

There's also overloading the search form, cart.attributes, cart.note or line item properties on products.

Each one comes with different behaviors and caveats, test thoroughly.

There are also alternate templates using the ?view= parameter

 

 and a dynamically created token over GET

Is this for the storefront api? or an app? if an app a consider a proxy

https://shopify.dev/tutorials/display-dynamic-store-data-with-app-proxies

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes