ShoppingCart::current PHP Method

current() public method

Get the current order, or return null if it doesn't exist.
public current ( ) : Order
return Order
    public function current()
    {
        //find order by id saved to session (allows logging out and retaining cart contents)
        if (!$this->order && ($sessionid = Session::get(self::config()->cartid_session_name))) {
            $this->order = Order::get()->filter(array("Status" => "Cart", "ID" => $sessionid))->first();
        }
        if (!$this->calculateonce && $this->order) {
            $this->order->calculate();
            $this->calculateonce = true;
        }
        return $this->order ? $this->order : false;
    }