woocommerce offtopic - Woo API REST : product variation price is read-only?

admin2025-04-18  0

I see price string Current variation price. [read-only] on this documentation (official api rest doc from WooCommerce).

Does it mean that it's impossible to make an app to update a product variation price ?

I see price string Current variation price. [read-only] on this documentation (official api rest doc from WooCommerce).

Does it mean that it's impossible to make an app to update a product variation price ?

Share Improve this question edited Nov 25, 2019 at 16:56 Kubadev asked Nov 25, 2019 at 15:48 KubadevKubadev 1217 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

After some research, i found this example : PUT /wp-json/wc/v3/products/<product_id>/variations/<id>

So in javascript we could do :

const data = {
  regular_price: "10.00"
};

WooCommerce.put("products/22/variations/733", data)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.log(error.response.data);
  });

And the JSON API Response :

{
  "id": 733,
  "date_created": "2017-03-23T00:53:11",
  "date_created_gmt": "2017-03-23T03:53:11",
  "date_modified": "2017-03-23T00:53:11",
  "date_modified_gmt": "2017-03-23T03:53:11",
  "description": "",
  "permalink": "https://example/product/ship-your-idea/?attribute_pa_color=green",
  "sku": "",
  "price": "10.00",
  "regular_price": "10.00",
  "sale_price": "",
  ...
}

I'll do some test, but i think it's possible to update a product variation price with WooCommerce API/REST.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744970606a277464.html

最新回复(0)