如何显示否。产品的售出单位或IT IT IT及其在Shopify中通过Liquid的变体

发布于 2025-02-05 07:51:34 字数 484 浏览 2 评论 0原文

我想显示针对特定产品出售的实际单位数量,访客可以看到他们正在寻找的产品是

x客户订购

出售<代码> y 单位<代码> x 24小时内的客户

我想通过液体实现此目的。 如果我可以得到初始&amp; 调整后的变体/产品清单,然后我可以从中减去 Current 库存并获得数字。请注意,调整后的库存是一个变量,我们将继续手动更改。

例如:初始库存:50

调整后(添加了更多):50

当前库存:40

,这意味着我们已经出售了(初始+调整后)-Current = 60单位。

请仅通过液体来帮助我实现这一目标。

I want to display the actual number of units sold for a particular product where visitors can see that the product they are looking at was

Ordered by x customers

or

Sold y units to x customers in 24 hours

I want to achieve this via Liquid.
If I can get the initial & adjusted inventory of a variant/product then I can subtract the current inventory from it and get a number. Note that Adjusted inventory is a variable that we will keep on changing manually.

Ex: Initial Inventory: 50

Adjusted (added more): 50

Current Inventory: 40

Which means that we've sold (initial+adjusted)-current = 60 units.

Please help me achieve this via Liquid only.

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

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

发布评论

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

评论(2

春花秋月 2025-02-12 07:51:34

在产品和变体对象上没有本机字段。但是,您可以使用Metafields来定义自己的字段:

然后,每当出售商品时,您都可以增加相应的metafield的值。查看 shopify webhooks 可以“等待”命令发生。

There is no native field for that on the product and variant object. However, you could use metafields to define your own field:

You could then increment the value of the respective metafield whenever an item is sold. Check out Shopify Webhooks to learn more about how you can "wait" for an order to happen.

音栖息无 2025-02-12 07:51:34

您确实需要使用Metafields来进行此操作,并且不需要应用程序,但是如果您确实使用了应用程序,那将是自动的。基本上,液体可以为被保存的元地区的客户提供任何价值。因此,如果您将一个数字分配给产品(例如60个),则客户可以阅读,如果您愿意,为“售出60个单位!”。问题是您将为每个销售手动更新该号码。笨拙!使用简单的几行代码,一个应用程序可以收听订单,并自动更新这些数字,因此从长远来看,您实际上什么也不做,但您的客户会获得更新的销售号码。由你决定。但是,没有什么手动地做这件事的方式。

You do want to use Metafields for this and you don't need an App, but it would be all automatic if you did use an App. Basically, Liquid can render any value to the customer saved as a Metafield. So if you assigned a number to a product, like 60, the customer could read that if you wanted, as "60 units sold!". The problem with that is you would manually update that number for each sale. Clunky! With a simple few lines of code, an App could listen for orders, and automatically update those numbers, so over the long term, you really do nothing and yet your customers get updated sales numbers. Up to you. But nothing is standing in your way of doing this manually.

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