SELECT SQL_CALC_FOUND_ROWS a.`id_order`, `reference`, `total_paid_tax_incl`, a.`payment` AS `payment`, a.`date_add` AS `date_add`, `order_id`, a.`id_currency`, a.`id_carrier`, a.`id_order` AS `id_pdf`, CONCAT(a.`id_customer`, '-', a.`id_order`) AS `id_message`, SUM(od.`product_customization_id`) as `custom`, CONCAT(c.`firstname`, ' ', c.`lastname`) AS `customer`, c.`id_default_group`, osl.`name` AS `osname`, carrier.`name` AS `caname`, os.`color`, IF(( SELECT so.`id_order` FROM `ps_orders` so WHERE so.`id_customer` = a.`id_customer` AND so.`id_order` < a.`id_order` LIMIT 1 ) > 0, 0, 1 ) AS `new`, country_lang.`name` AS `cname`, IF(a.`valid`, 1, 0) `badge_success`, mol.`transaction_id` FROM `ps_orders` a STRAIGHT_JOIN `ps_customer` c ON(c.`id_customer` = a.`id_customer`) STRAIGHT_JOIN `ps_shop` s ON(s.`id_shop` = a.`id_shop`) STRAIGHT_JOIN `ps_address` address ON(address.`id_address` = a.`id_address_delivery`) LEFT JOIN `ps_order_carrier` oc ON(oc.`id_order` = a.`id_order`) LEFT JOIN `ps_carrier` carrier ON(carrier.`id_carrier` = a.`id_carrier`) LEFT JOIN `ps_country` country ON(country.`id_country` = address.`id_country`) LEFT JOIN `ps_country_lang` country_lang ON(country_lang.`id_country` = country.`id_country` AND country_lang.`id_lang` = 1 ) LEFT JOIN `ps_order_state` os ON(os.`id_order_state` = a.`current_state`) LEFT JOIN `ps_order_payment` op ON(op.`order_reference` = a.`reference`) LEFT JOIN `ps_order_state_lang` osl ON(osl.`id_order_state` = os.`id_order_state` AND osl.`id_lang` = 1 ) LEFT OUTER JOIN `ps_order_detail` od ON(od.`id_order` = a.`id_order`) LEFT JOIN `ps_mollie_payments` mol ON mol.`order_reference` = a.`reference` AND mol.`cart_id` = a.`id_cart` AND mol.order_id > 0 WHERE 1 AND a.`archived` = 0 GROUP BY a.`id_order` ORDER BY a.`id_order` DESC LIMIT 0, 300