0

From quote I got array of customizable option. How can I retrieve it's title & value

 $quote = $this->_cart->getQuote();
    $cartAllItems = $quote->getAllItems();
    foreach ($cartAllItems as $item) {
        foreach ($item->getOptions() as $option) {

             echo "<pre>";
            print_r(json_decode($option['value']));die;

        }

This is the output but I need value

[options] => stdClass Object
    (
        [1] => Array
            (
                [0] => 2
            )

    )
1
// 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']; 
            $optionValue = $option['value'];
        }
    }
}

NOTE in above code $cart is object of Magento\Checkout\Model\Cart

| improve this answer | |

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.