I’m trying to send a new variation to a woocommerce product. It is correctly created except for the attribute.
I’m sending:
$data = [
'sku'=> $confezione['CODART'],
'price' => $confezione['PREZZO1'],
'regular_price' => $confezione['PREZZO1'],
'attributes' => [
[
'id' => 3,
'name' => 'confezionamento',
'slug' => 'pa_confezionamento',
'options' => $tipo
]
]
];
and the [attributes]
is empty
[attributes] => Array
(
[0] => stdClass Object
(
[id] => 3
[name] => confezionamento
[slug] => pa_confezionamento
[option] => FL 12 x 1 lt
)
)
If I compile the variation manually the following attribute is created.
The attributes in product are:
[attributes] => Array
(
[0] => stdClass Object
(
[id] => 3
[name] => confezionamento
[slug] => pa_confezionamento
[position] => 0
[visible] => 1
[variation] => 1
[options] => Array
(
[0] => FL 12 x 1 lt
[1] => FL 12 x 750 ml
[2] => TA 10 lt
[3] => TA 20 lt
[4] => TA 4 x 5 lt
)
)
)
Where is my mistake?
New contributor
mcm_mcm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.