public function findOrMakeCart()
    {
        $cookies = $this->cookiesSupported();
        $session = $this->getSession();
        $classname = self::config()->model;
        $cart = null;
        $write = false;
        $member = Security::getCurrentUser();

        if ($cookies) {
            $cart_id = Cookie::get(self::COOKIE_NAME);
        } else {
            $cart_id = $session->get(self::COOKIE_NAME);
        }

        // Try to get a cart from the the DB
        if (isset($cart_id)) {
            $cart = $classname::get()->find('AccessKey', $cart_id);
        }

        // Does the current member have a cart?
        if (empty($cart) && isset($member) && $member->getCart()) {
            $cart = $member->getCart();
        }

        // Finally, if nothing is set, create a new instance to return
        if (empty($cart)) {
            $cart = $classname::create();
        }

        return $cart;
    }
public function findOrMakeCart()
    {
        $cookies = $this->cookiesSupported();
        $session = $this->getSession();
        $classname = self::config()->model;
        $cart = null;
        $write = false;
        $member = Security::getCurrentUser();

        if ($cookies) {
            $cart_id = Cookie::get(self::COOKIE_NAME);
        } else {
            $cart_id = $session->get(self::COOKIE_NAME);
        }

        // Try to get a cart from the the DB
        if (isset($cart_id)) {
            $cart = $classname::get()->find('AccessKey', $cart_id);
        }

        // Does the current member have a cart?
        if (empty($cart) && isset($member) && $member->getCart()) {
            $cart = $member->getCart();
        }

        // Finally, if nothing is set, create a new instance to return
        if (empty($cart)) {
            $cart = $classname::create();
        }

        return $cart;
    }
public function findOrMakeCart ( ) { $ cookies = $ this -> cookiesSupported ( ) ; $ session = $ this -> getSession ( ) ; $ classname = self :: config ( ) -> model ; $ cart = null ; $ write = false ; $ member = Security :: getCurrentUser ( ) ; if ( $ cookies ) { $ cart_id = Cookie :: get ( self :: COOKIE_NAME ) ; } else { $ cart_id = $ session -> get ( self :: COOKIE_NAME ) ; } // Try to get a cart from the the DB if ( isset ( $ cart_id ) ) { $ cart = $ classname :: get ( ) -> find ( 'AccessKey' , $ cart_id ) ; } // Does the current member have a cart? if ( empty ( $ cart ) && isset ( $ member ) && $ member -> getCart ( ) ) { $ cart = $ member -> getCart ( ) ; } // Finally, if nothing is set, create a new instance to return if ( empty ( $ cart ) ) { $ cart = $ classname :: create ( ) ; } return $ cart ; }
Either find an existing cart, or create a new one.

@return ShoppingCartModel
Either find an existing cart or create a new one .