Reputation: 13
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). 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:
What's the best way to store this information? Using product.options
doesn't seem ideal, since each product can only have 3 options. So it seems like the options are either product metafield or as a tag?
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. Is there an API to do that? Or am I maybe (hopefully!) overcomplicating things, and this can be done outside of using the APIs entirely?
I'm pretty new to shopify development, so appreciate the help!
Upvotes: 0
Views: 570
Reputation: 1324
What's the best way to store this information? Using product.options doesn't seem ideal, since each product can only have 3 options. 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
Upvotes: 1