Update product price via API

Solved
Highlighted
Tourist
5 1 2

Hey everyone - very quick question.  How do you update a product's price via the API? Just including a "price" key/value in the PUT/POST payload isn't doing the trick.  Do I have to create a product variant for this, even if my product has no variants?

 

Thanks for your help!

0 Likes
Highlighted
Shopify Partner
191 13 36

Hi @anonymous1 ,

 

Use your product ID for variant ID see if that works. Also wouldn't hurt to show us what you're payload and any errors.

 

Regards,

 

Sam

Shopify Themes and Custom Apps | hello@achieveapplabs.com
0 Likes
Highlighted
Tourist
5 1 2

Thanks!  I guess that's my question - do you have to update a "variant" to update price?  The docs are surprisingly silent about what I would think would be a top-level  operation for any Shopify dev - updating price via API.

 

Here's what my payload looks like to the /products endpoint:

product_payload = {
    'product': {
        'title': self.title,
        'body_html': self.description,
        'published': self.published,
        'price': json.dumps(self.price, use_decimal=True)
    }
}

Everything but price gets updated/set correctly.

 

Thanks for your time!

0 Likes
Highlighted

Success.

Tourist
5 1 2

I want to respond to my own thread here with the solution.  A thing that is not 100% clear about Shopify products is that they DO NOT have a price associated with them.  Only the product VARIANTS have prices.  Even if you have a product with no variants, Shopify has secretly created a single variant for your product and this is the object that contains your price.  So if you wanted to update your product's price, you can't make a call to /products/{product.id}.json you have to call /variants/{variant.id}.json with price as part of the payload.  A bit confusing and not exactly spelled out, but makes sense!

2 Likes