Home » Magento

Magento: Get Custom Option Value from Order

4 March 2013 Share/Bookmark

This article contains code snippet to get custom options value of all products in any Magento order.

Suppose, there is a product with a custom option dropdown list. You chose one of the option from the dropdown list and purchased that product. The code below fetches product’s custom option value selected in any particular order.

Here is the code:-

$incrementId = '100000042';
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
foreach ($order->getAllItems() as $item) {
    $options = $item->getProductOptions(); 
    $customOptions = $options['options'];   
    if(!empty($customOptions))
    {
	foreach ($customOptions as $option)
	{	    
	    $optionTitle = $option['label'];
	    $optionId = $option['option_id'];
	    $optionType = $option['type'];
	    $optionValue = $option['value'];
	}
    }
}

Hope it helps.
Thanks.

From Mukesh Chapagain's Blog, post Magento: Get Custom Option Value from Order

email

php magento mukesh chapagain

Get New Post by Email
RSS Feed Subscribe RSS Feed