Hi I’m new in woocomrece API
and I want to send an image for my product, but every time I refresh the code with the same URL link new image media add to my WordPress media with a new link, and after like 10 times I have 10 duplicates of an image in media
<?php
$data = [
'name' => $name,
'type' => 'variable',
'regular_price' => '50',
'description' => $description,
'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
'categories' => [
[
'id' => $id_19
],
[
'id' => $id_23
]
],
'images' => [
[
'src' => 'http://localhost/wordpress/wp-content/uploads/2022/03/arian-logo-1.png',
]
],
'attributes' => [
[
'name' => 'color',
'position' => 0,
'visible' => true,
'variation' => true,
'options' => [
'Black',
'Green'
]
],
[
'name' => 'Size',
'position' => 0,
'visible' => true,
'variation' => true,
'options' => [
'S',
'M'
]
]
],
'default_attributes' => [
[
'name' => 'color',
'option' => 'Black'
],
[
'name' => 'Size',
'option' => 'S'
]
]
];
($woocommerce->post('products', $data));
?>