Liquid - 获取产品 ID 并动态显示自定义/特定信息

发布于 2025-01-12 13:15:59 字数 479 浏览 3 评论 0原文

我正在尝试向页面添加一个小的“锁定”/促销,该页面根据 page.metafield 信息动态加载信息。替换图像、视频 ID 等。一切都很好。

我的客户要求一个小区域来展示与这种动态变化的内容相关的产品,我正在努力想出一个好方法来做到这一点。

当前的设置是我们有 30 个页面,每页有一组 8 个元字段。每个页面都必须显示不同的单一产品,其中包含图像、标题、价格、购买按钮和另一个链接到合作伙伴网站的按钮。

我可以创建代码片段并通过元字段手动加载几乎所有这些信息(价格、标题等,客户端可以添加到另一个元字段),但我更愿意加载一个产品来提取这些信息,以便可以将其添加到购物车。尽管我可以手动添加产品数据,但我实际上仍然不知道哪个产品将添加到购物车,因为我位于“页面”而不是“产品”上。

产品本身使用与网站其他部分不同的自定义模板,因此这似乎不是一个选项。此内容页面的模板只是“页面”,但我肯定可以以某种方式调用产品对象吗?如果客户在元字段中输入产品 ID,是否有办法轻松提取该 ID 数据?

I am trying to add a small 'lockup' / promo to a page that loads information dynamically based on page.metafield information. Replacing images, video ID's etc. Which all works just fine.

My client is asking for a small area to display a product that relates to this dynamically changing content and I am struggling to come up with a good way to do this.

The current setup is that we have 30 pages with a set of 8 metafields each page. Each one of these pages must show a different , single product with an image, title, price, buy button and another button that links out to a partner site.

I can create snippet and load almost all of this info through metafields manually (price, title etc the client could just add to another metafield) but I would prefer to load a product to pull this info so it can be added to cart. Although I can add product data manually, I still don't actually know which product will get added to the cart, because I'm on a 'page' not a 'product'.

The products themselves are using a custom template that is different to the rest of the site so that seems like its not an option. The template for this content page is just 'page' but surely I can call the product object someway? If the client entered a product ID in the metafields, is there a way of pulling that IDs data easily?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走走停停 2025-01-19 13:15:59

不管你说的提取 ID 是什么意思,有几种方法可以解决这个问题。一,你有一个 Storefront API 令牌,允许你自由安全地用 JS 调用 Shopify 并取回有关你感兴趣的 ID 的所有数据。或者,你在商店中安装了一个应用程序,在这种情况下你可以设置并回调应用程序代理,提供该 ID,并获取您需要的所有信息。很多选择!

Whatever you mean by pulling ID's, but there are a couple of ways of dealing with this. One, you have a Storefront API token, allowing you to freely and securely call Shopify with JS and get back all the data about the ID you're interested in. Or, you have an App installed in the store, in which case you can setup and callback an App Proxy, providing that ID, and getting back all the info you need. Lots of options!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文