0

I want to retrieve the list of items in a customer's shopping cart programmatically through REST API. I have tried this code and other similar ones on stackexchange for which each fail to retrieve the list of items in the customers shopping cart. Access to the REST Service(consumer key and tokens) are valid.

// retrieve quote items collection
$itemsCollection = Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection();

// get array of all items what can be display directly
$itemsVisible = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();

// retrieve quote items array
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach($items as $item) {
    echo 'ID: '.$item->getProductId().'<br />';
    echo 'Name: '.$item->getName().'<br />';
    echo 'Sku: '.$item->getSku().'<br />';
    echo 'Quantity: '.$item->getQty().'<br />';
    echo 'Price: '.$item->getPrice().'<br />';
    echo "<br />";            
}
0

The code you referenced is not for getting the shopping cart items through API - it's for getting those items in Magento.

What you'll need to do is write a module that has an API endpoint and the API will return the data from the collection that you referenced to.

Out of the box, Magento doesn't have an API endpoint for returning items in a customer's cart.

  • Any idea on how to specifically access sales_flat_quote_item table/model as it stores the cart items for customers? – tej-kweku Nov 5 '18 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.