id_lang){ @$cookie->id_lang = 2; } $sql = ' SELECT o.`id_order`, (od.`product_quantity` - ( od.`product_quantity_refunded` + od.`product_quantity_return`)) AS `quantity` FROM `ps_order_detail` od LEFT JOIN `ps_orders` o ON (o.`id_order` = od.`id_order`) WHERE o.`valid` = 1 AND od.`product_id` IN ( SELECT cache.`id_product` FROM `ps_product_ps_cache` cache WHERE cache.`id_sale` = 3986 ) AND o.id_order <> 238884 '; $details = Db::getInstance()->executeS($sql); // :215569 => Commande test pour >>>> thibault@antadis.com // test sendMail ProductVouchers::sendMail(1, 215569, 'TEST'); foreach ($details as $key => $detail) { ProductVouchers::associateCodeToOrder(1, $detail['quantity'], $detail['id_order']); }