Answers for "magento 2 display product selected option in cart"

0

magento 2 display product selected option in cart

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 
 
// get cart items
$items = $cart->getItems();
 
// get custom options value of cart items
foreach ($items as $item) {
    $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
    $customOptions = $options['options'];
    if (!empty($customOptions)) {
        foreach ($customOptions as $option) {
            $optionTitle = $option['label'];
            $optionId = $option['option_id'];
            $optionType = $option['type'];
            $optionValue = $option['value'];
        }
    }
}
Posted by: Guest on November-11-2020

Code answers related to "magento 2 display product selected option in cart"

Browse Popular Code Answers by Language