Finding the products in a sale

Solved
BeamJokerFavor
Excursionist
36 2 2

When I sell a variant, I want to archive all other variants of that product.

I sell a variant. At a designated time I want to to query all sales and find the product ID of the parent products sold, so I can archive the parent product.

Alternatively, is there a way to listen for a sale to trigger my expiration script?

Not looking for code help, more looking for API reference and architecture help.

0 Likes
_JB
Shopify Staff
Shopify Staff
834 98 183

This is an accepted solution.

Hey @BeamJokerFavor,

You can subscribe to the orders#create webhook which will contain the product_id for all items on the order. Using the product_id you can make an API call to change the product's status to archived.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

BeamJokerFavor
Excursionist
36 2 2

Perfect, this will keep me from polling the API.

0 Likes