public static function removeProductSale($id_product, $qty = 1) { $total_sales = ProductSale::getNbrSales($id_product); if ($total_sales > 1) { return Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'product_sale SET `quantity` = `quantity` - ' . (int) $qty . ', `sale_nbr` = `sale_nbr` - 1, `date_upd` = NOW() WHERE `id_product` = ' . (int) $id_product); } elseif ($total_sales == 1) { return Db::getInstance()->delete('product_sale', 'id_product = ' . (int) $id_product); } return true; }