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?