'Display alt product/json data via shopify app proxy in existing shopify product theme
I want to display a modified version of a product page - for example, something as simple as not displaying the buy button, based on an external validation/check. theoretically, it's not that complicated, but I'm stuck.
Here is what I know/see/understand. In liquid code, there is templates -> product.json sections -> main-product.liquid
I created templates -> product.alternate.json (a duplicate of product.json minus the buy button) snippets -> alternate-product.liquid (which is just content_for_layout)
changes in template.liquid to handle the a product template
If I change the product template to alternate - my snippet correctly loads and the alternate product without the buy button is displayed correct.
I change alternate-product.liquid to do an ajax call to to get app proxy.
On app proxy I've tried
- returning the same data as product.json, liquid content type this didn't show anything in the body (header and footer are there)
- using the site access token to fetch a hardcoded product by id and returning this json (content-type json), same, it's just header and footer.
What I'm trying to do is use a $.get('/apps/s/serve/some-unique-id') that will render the correct json/liquid that shows or doesn't show, the buy now button "some-unique-id" is a client side id.
I know we can manually create the needed HTML tags server side and send them - but this doesn't use the theme/style that's already applied for the rest of the shopify site.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
