📣 The forum has moved to GitHub
We’ve switched to GitHub Discussions as the hub for our community. This will improve the experience of collaborating for everyone, sharing what you’re working on, and discussing ideas for how Swell can be improved. Existing threads will remain open, but new posts are disabled.
Go to GitHub →Can't update product price via API
I am trying to update a product's price through the API (https://swell.store/docs/api/#update-a-product). However the price does not update. Below is an example response when trying to update a price from $500 to $650. The price
field is updated to the new value ($650) in the response object, but the purchase_options.standard.price
, and the $currency.USD.price
are still the old value. Then when I retrieve the product again (https://swell.store/docs/api/#list-all-products), the price is still the original value ($500).
Example Request Body:
{ id: 'swell-product-id', price: 650, }
Example Response:
{ attributes: {}, name: 'PRODUCT_NAME', price: 650, // <-- updated price seller_id: 'seller-id', currency: 'USD', slug: 'post-slug', date_created: '2022-03-09T09:45:04.824Z', active: true, stock_status: null, date_updated: '2022-03-22T09:13:26.358Z', description: null, images: null, meta_description: null, meta_title: null, options: [], prices: [], purchase_options: { standard: { active: true, price: 500, // <-- old price sale: false, sale_price: null, prices: [], '$currency': [Object] } }, sale: false, sale_price: null, sku: null, tags: [], variable: false, id: 'swell-product-id', '$locale': { 'en-US': { name: 'PRODUCT_NAME', description: '', tags: [], meta_title: '', meta_description: '' } }, '$currency': { USD: { price: 500, sale_price: '' } } // <-- old price }
Answers
-
This happens when you have Multi-currency enabled in your store.
To update the price, I suggest doing it this way:
{ "purchase_options": { "standard": { "price": YOUR-NEW-PRICE } } }
Gonzalo | Technical Account Manager @ Swell
0