$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$orderObject = $objectManager->get(‘\Magento\Sales\Model\Order’);

// load by order id
$orderId = 1000101; // YOUR ORDER ID
$order = $orderObject->load($orderId);

// load by order increment id
// $incrementId = ‘012378001’; // YOUR ORDER INCREMENT ID
// $order = $orderObject->loadByIncrementId($incrementId);

$oritems = $order->getAllVisibleItems();
// $items = $order->getAllItems();

foreach ($oritems as $item) {
$options = $item->getProductOptions();
if (isset($options[‘options’]) && !empty($options[‘options’])) {
foreach ($options[‘options’] as $option) {
echo ‘Order Title: ‘ . $option[‘label’] . ‘<br />’;
echo ‘Order ID: ‘ . $option[‘option_id’] . ‘<br />’;
echo ‘Order Type: ‘ . $option[‘option_type’] . ‘<br />’;
echo ‘Order Value: ‘ . $option[‘option_value’] . ‘<br />’;
}
}
}

Please login or Register to submit your answer

Log In

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