Jump to content

Order::getorderbycartid Doesn't Deliver The Promised Result


EC1

Recommended Posts

/**
     * Get an order by its cart id
     *
     * @param int $id_cart Cart id
     * @return array Order details
     */
    public static function getOrderByCartId($id_cart)
    {
        $sql = 'SELECT `id_order`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_cart` = '.(int)$id_cart
                    .Shop::addSqlRestriction();
        $result = Db::getInstance()->getRow($sql);
 
        return isset($result['id_order']) ? $result['id_order'] : false;
    }
 

This will only return the id of the order. Depending on the intended use, either change the name to getOrderIdByCartId or change the function. Maybe...


    public static function getOrderByCartId($id_cart)
    {
        $order = new Order($id_cart);
        return isset($order->id) ? $order : false;
    }

Thanks!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...