Archive for July, 2010

getOrderByCartId(intval($id_cart)) Prestashop Function

July 1st, 2010

the getorderByCart function simply returns the order_id when the input is a cart_id, located in /classes/order.php the function is as follows

/**
	 * Get an order by its cart id
	 *
	 * @param integer $id_cart Cart id
	 * @return array Order details
	 */
	static public function getOrderByCartId($id_cart)
    {
    	$result = Db::getInstance()->getRow('
        SELECT `id_order`
        FROM `'._DB_PREFIX_.'orders`
        WHERE `id_cart` = '.intval($id_cart));

		return isset($result['id_order']) ? $result['id_order'] : false;
    }

example of use

$myid_order = Order::getOrderByCartId(intval($id_cart));