简体   繁体   中英

how can I override the data that is rendered on shopify .liquid with the need for using Ajax

I have a use case where I want to implement custom search functionality for a Shopify site. So instead of using getting a JSON with Ajax and making a html and replacing the html. Is there a way where I can override the search.results data that the .liquid files are using.

So when I make a search in /search?q=xyz , I want to get the data from my API , and use that data to render the product-item.liquid . This way I don't have to worry about the UI of the product-item for different themes.

Yes. You can easily do this. You would install an App in your shop, and create an endpoint you would call with your search criteria. The end point is handled by a Shopify App Proxy, that securely allows you to callback the App. You could return Liquid as results, or just JSON as you wish. It is a standard and simple pattern for you to use.

See here: https://help.shopify.com/api/tutorials/application-proxies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM