简体   繁体   English

添加到购物车之前更新产品属性 - shopify 主题应用程序扩展

[英]Updating product properties before adding to cart - shopify theme app extension

I'm trying to implement functionality in a shopify theme app extension, where when the user clicks a checkbox, extra information about the selected product is added (like a product option).我正在尝试在 shopify 主题应用程序扩展中实现功能,当用户单击复选框时,会添加有关所选产品的额外信息(如产品选项)。 If the user then adds the product to cart, this extra information is passed along with the product, so that it can be later tracked and used in checkout.如果用户随后将产品添加到购物车,则此额外信息将与产品一起传递,以便以后可以跟踪并在结帐时使用。

I have two main questions:我有两个主要问题:

  1. What's the best way to store this information?存储此信息的最佳方式是什么? Using product.options doesn't seem ideal, since each product can only have 3 options.使用product.options似乎并不理想,因为每个产品只能有 3 个选项。 So it seems like the options are either product metafield or as a tag?所以看起来选项要么是产品元字段,要么是标签?

  2. In reading the docs, I see there are POST APIs to update a product itself or to update a line of a Cart in the Admin API. However, I want to update information about a selected product, before it is added to the cart.在阅读文档时,我看到有 POST API 可以更新产品本身或更新 Admin API 中的购物车行。但是,我想在将所选产品添加到购物车之前更新有关该产品的信息。 Is there an API to do that?是否有 API 可以做到这一点? Or am I maybe (hopefully,) overcomplicating things?还是我可能(希望)使事情过于复杂? and this can be done outside of using the APIs entirely?这可以在完全使用 API 之外完成吗?

I'm pretty new to shopify development, so appreciate the help!我是 shopify 开发的新手,非常感谢您的帮助!

What's the best way to store this information?存储此信息的最佳方式是什么? Using product.options doesn't seem ideal, since each product can only have 3 options.使用 product.options 似乎并不理想,因为每个产品只能有 3 个选项。 So it seems like the options are either product metafield or as a tag?所以看起来选项要么是产品元字段,要么是标签?

Product options are not supposed to store such pieces of information.产品选项不应存储此类信息。 Options are options and any app (most likely) shouldn't touch it.选项就是选项,任何应用程序(很可能)都不应该触及它。 It could mess up many parts of the theme and disallow merchants to add more options to the product.它可能会弄乱主题的许多部分,并不允许商家为产品添加更多选项。

Line item properties aren't used for that purpose either.订单项属性也不用于该目的。 Usually, they are helpful for storing data that needs to be used in integrations/promotions.通常,它们有助于存储需要在集成/促销中使用的数据。

Your best choice is meta fields.您最好的选择是元字段。 You should also look into Checkout UI Extensions API which in case of publishing app will be welcome from Shopify's perspective您还应该查看Checkout UI Extensions API ,从 Shopify 的角度来看,如果发布应用程序将受到欢迎

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

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