Ecommerce Shopify WordPress Discussion

How to add multiple images to an existing product with the WooCommerce API

I want to add one or more images to an existing product that already has images within WooCommerce. function addImage($sku, $images){ global $woocommerce; //Get id from sku $products = $woocommerce->get('products/?sku='. $sku); $id = $products->id; $image_count = count($products->images); $item_data = [ 'images' => [ [ 'src' => $images, 'position' => $image_count + 1, ], ], ]; $products = $woocommerce->post('products/'.$id, $item_data); echo '<pre>'; print_r($products); echo '</pre>'; } In my code it replaces the images that the product already has but does not add to the existing ones. I tried to use positions of the images but it still doesn't add. The same thing happens with the put and get methods. Someone already managed to do this.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.