简体   繁体   English

如何开发在产品页面中进行更改的shopify应用程序?

[英]How to develop a shopify application that make change in product page?

I'm trying to develop a Shopify recommendation app that will embed recommended bundle products to the shop's product page as similar as Shopify official product review app that embeds a review section (Customer Review) to the product page by adding the following section to the template:我正在尝试开发一个 Shopify 推荐应用程序,它将推荐的​​捆绑产品嵌入到商店的产品页面,类似于 Shopify 官方产品评论应用程序,通过将以下部分添加到模板中,将评论部分(客户评论)嵌入到产品页面:

<div id="shopify-product-reviews" data-id="{{product.id}}">
    {{ product.metafields.spr.reviews }}
</div>

:

顾客评论

My question is about the way of implementing a Shopify application that works as a widget in the product page.我的问题是关于在产品页面中实现作为小部件的 Shopify 应用程序的方式。 As far as I understand Shopify App Proxy is doing a similar thing but it renders the template on a new page, I can't find any approach to embed my liquid template to the existing theme.据我了解Shopify App Proxy正在做类似的事情,但它在新页面上呈现模板,我找不到任何方法将我的液体模板嵌入到现有主题中。

You are missing a beautiful and most useful aspect of App Proxy.您错过了 App Proxy 一个美丽且最有用的方面。 With it you can do the following pattern, answering your needs perfectly.有了它,您可以执行以下模式,完美满足您的需求。

  • send the App Proxy the product being viewed using a Javascript GET使用 Javascript GET 向应用代理发送正在​​查看的产品
  • The App Proxy will securely get any information you deem important for you based on the incoming product information应用代理将根据传入的产品信息安全地获取您认为对您重要的任何信息
  • You can return pure JSON data as the answer from the Proxy, back to the request您可以从代理返回纯 JSON 数据作为答复,返回到请求
  • Using any old template pattern you want, you can take the JSON returned from the Proxy and render useful HTML for the customer使用您想要的任何旧模板模式,您可以获取从代理返回的 JSON 并为客户呈现有用的 HTML

While it is true the App Proxy can be used to return Liquid, this will indeed mean a re-rendering of the screen chrome and layout, so you might prefer the JS and template method.虽然 App Proxy 确实可以用于返回 Liquid,但这确实意味着屏幕镶边和布局的重新渲染,因此您可能更喜欢 JS 和模板方法。 However, I have used both, and both are super for their own purposes.但是,我两个都用过,而且都非常适合自己的目的。 Returning Liquid is cool as it lets you write Liquid in the Shopify Theme that you can populate in your App, and Shopify will then populate the Product info allowing for you to have Theme Designers and the merchant change the HTML the customer sees, without the HTML template limits the JSON approach has. Returning Liquid 很酷,因为它可以让您在 Shopify 主题中编写 Liquid,您可以将其填充到您的应用程序中,然后 Shopify 将填充产品信息,允许您让主题设计师和商家更改客户看到的 HTML,而无需 HTML模板限制了 JSON 方法。

I am also developing a custom product page.我也在开发自定义产品页面。 I guess the process should be like this:我想流程应该是这样的:

  1. When a merchant installs your app, use ScriptTag API to add your js to the product page当商家安装您的应用时,使用 ScriptTag API 将您的 js 添加到产品页面
  2. When a product page is loaded, use js to send GET request to App proxy加载产品页面时,使用js向App代理发送GET请求
  3. App proxy redirects to your app.应用代理重定向到您的应用。 Your app will return the JSON response您的应用将返回 JSON 响应
  4. your js get and parse the response, dynamically add the widget on the product page您的 js 获取并解析响应,在产品页面上动态添加小部件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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