Accessing array elements WOOCOMMERCE API

I would really appreciate who can guide me with the following:

I have the following ARRAY, it is a record of a product in woocommerce-wordpress that RETURNS three DIFFERENT variations: 1837, 1838 and 1839.

Array
(
[0] => stdClass Object
(

[variations] => Array
(
[0] => 1837
[1] => 1838
[2] => 1839
)

)
)

I need to be able to ACCESS the ARRAY of all the products that the woocommerce api returns and then modify the price that each variation has.

I understand that first I have to ACCESS all products with:

$woocommerce-> get (‘products’)

Then I NEDD TO ACCESS TO all variations of each product with:

$woocommerce-> get (‘products / <id-variacion> / variations’)

and finally to update the price of each variation with:

$data = [‘regular_price’ => ’10 .00 ‘];

$woocommerce-> put (‘products / <id-product> / variations / <id-variacion>’, $ data)

I don’t have much code to show yet because I’m testing and learning, that’s why I’m asking for guidance.

Read more here:: Accessing array elements WOOCOMMERCE API

Leave a Reply

Your email address will not be published. Required fields are marked *