Hello,
instead of the code above, I placed the custom variations in fourth parameter. I did this:
$res = $cart->add_to_cart(
$product_id,
$value->qty,
$variation_id,
array(),
array(
‘my_index_’ => array(
‘Freebies’ => $value->freeproduct,
‘Quantity’ => $value->qty,
‘Country’ => $country
)
)
);
Note: This will not fix the issue, will just help you to display and to have custom variations easily. The variations you set in the admin are still there and will show in the cart, you have to call another filter to hide them and you have to call another filter to show your custom variations. Be very careful might affect all products so be sure in the filter check what’s inside the cart first before applying the hack.