It depends on what you are trying to accomplish. If you are in the admin and you need to add the product to the cart (although the administrator already has this feature), you would have done it differently than when you are in the external interface. One of the key points that are a bit confusing in Magento is that there really aren't things on the cart that store items - quote . The cart is a wrapper for a quote. If you think about it a little, it really makes sense.
So, to access the client’s quote from the administrator, do the following:
$quote = Mage::getModel('sales/quote')->loadByCustomer($customer); $quote->addProduct($product, $qty); $quote->collectTotals()->save();
If you want to access the quotation of the client from the external interface, you would do it as follows:
$quote = Mage::getSingleton('checkout/session'); $quote->addProduct($product, $qty); $quote->collectTotals()->save();
source share