Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I am working on a script to retrieve the information about products ordered and display it in a useful way to my team.
After updating the label of a product to standardize it with other products the variant_id for this sku has changed.
So when I take the variant_id of a line_item from an order made before the update we can't find the variant information anymore.
How can we access the information of the variant_id when it has been deprecated?
Using Myshop.myshopify.com/admin/api/2022-04/variants/variant_id.json
returns "not found"
Hello @Kittelog
If you are unable to retrieve the information of a variant using the deprecated variant ID, you can try the following steps:
Find the new variant ID: After updating the label of a product, the variant ID may change. To retrieve the new variant ID, you can use the Shopify Admin API's "List all variants" endpoint. This endpoint will return a list of all variants for a specific product.
The API endpoint to use is: GET /admin/api/2022-04/products/{product_id}/variants.json
Replace {product_id} with the ID of the product for which you need to find the new variant ID. Iterate through the response to locate the variant with the updated label and note its new variant ID.
Update your script: Once you have obtained the new variant ID, update your script to use the updated variant ID instead of the deprecated one. Replace the old variant ID with the new one in your script's logic or API requests.
For example, instead of using Myshop.myshopify.com/admin/api/2022-04/variants/variant_id.json, use Myshop.myshopify.com/admin/api/2022-04/variants/new_variant_id.json where new_variant_id is the updated variant ID.
Test the script: After updating your script with the new variant ID, test it by retrieving the variant information using the updated endpoint or logic. Make sure the variant information is correctly retrieved and displayed as expected.
By following these steps, you should be able to access the information of the variant even after the variant ID has changed due to label updates or other changes to the product.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025