$object->add_product not working

I am trying to create orders dynamically with products already in there. This is the code I am trying to implement, the order is created but no product is added.

$object = new Commande($db);
$object->socid = $socid;
$object->fetch_thirdparty();
$object->date_commande = $datecommande;
$object_id = $object->create($user);
foreach ($prodqties as $prod => $qty) {
    $object->add_product($prod, $qty);
}
$db->commit();

When I print the object, it contains the product in there, but it isn’t added to the db… Anybody has any idea why it isn’t working? Do I have to call another function before?

Hi,
The add_product function is attractive, but not saving lines indeed. The header comment says “TODO : modify this function with calls to addline” so that the lines will be effectively inserted. So you have two options : do the TODO (ie modify the add_product function) or replace by a call to addline (which expects a higher number of arguments).
Regards,
Marc