I want to fetch all product id that selected on cart page in phtml file. someone please send me some link or tutorial that i want to fetch product id's that selected in cart page through phtml file.

1 Answer 1

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 

 $items = $cart->getQuote()->getAllItems();

foreach($items as $item) {
     echo 'ID: '.$item->getProductId().'<br />';
     echo "<br />";            

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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