LE224 Posted November 17, 2015 Share Posted November 17, 2015 (edited) Hi, I already have a working and tested SQL statement below. SELECT COUNT(DISTINCT 'ps_cart_product.id_product') FROM 'ps_orders' INNER JOIN 'ps_cart_product' ON 'ps_orders.id_cart'='ps_cart_product.id_cart' WHERE 'ps_orders.id_customer' = 1; Thanks, LE224 [sOLVED] public static function getUniqueCustomerNbOrders($id_customer) { $sql = 'SELECT COUNT(DISTINCT c.`id_product`) AS nb FROM `'._DB_PREFIX_.'orders` o INNER JOIN `'._DB_PREFIX_.'cart_product` c ON (o.`id_cart`=c.`id_cart`) WHERE o.`id_customer` = '.(int)$id_customer; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return isset($result['nb']) ? $result['nb'] : 0; } Edited November 17, 2015 by LE224 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now