I've in my order a simple product with a custom option of type radio for choose

Product price 100
() no installation service
(*) yes install it + 50 €

Now I'm exporting my order to an ERP product and in my order_item I have the total price (100+ 50) but I need to know if one of the option is selected and the option price.

My problem is How I can get the price of a product's custom option starting from an order_item object ?

I've tried the info_buyRequest and I get the option but no option price

Array (
    [info_buyRequest] => Array         ( 
        [uenc] => a....0lEPVU,
         [product] => 29517
         [options] => Array  (
                 [66668] => 134343 )
         [qty] => 0
         [return_url] =>
         [related_product] =>          )
   [options] => Array         (
         [0] => Array                 (
                 [label] => Servizi aggiuntivi 
                 [value] => Installazione (Include trasporto al piano) e ritiro usato
                 [print_value] => Installazione (Include trasporto al piano) e ritiro usato
                 [option_id] => 66668
                 [option_type] => radio
                 [option_value] => 134343
                 [custom_view] =>                  )

Then after some google I'm able to load the product options using:

$product = Mage::getModel('catalog/product')->load($item->getProductId());
$options = Mage::getModel('catalog/product_option')->getProductOptionCollection($product);
                foreach ($options as $option) {

The above get me all product's custom option and respective value but, how I can match the product's custom options and the one selected in the order_item?

the option_id 66668 and the value of 13434 is only present on the table sales_flat_quote_item_option (with no price) and in the catalog_product_option_xx there is no option with id 66668...

2 Answers 2


You can try code given below. It works for me hope also help you.

$options = $item->getBuyRequest()->getData('options');
$totalCustomOptionPrice = 0;

foreach ($options as $key => $value) 
    $optionData = $item->getProduct()->getOptionById($key);
    if ($optionData['type'] == 'field') 
        $totalCustomOptionPrice = $optionData['price'];
        foreach($value as $optionId)
             foreach ($optionData->getValues() as $v) 
                 if ($v['option_type_id'] == $optionId) 
                     $totalCustomOptionPrice += $v->getPrice();
  • Works perfect :) Feb 7, 2017 at 8:39
  • I haven't tested this, but it looks like it would only retrieve the price as set in the product when the code runs, not which could be different than when the order was created. If someone makes a product, accepts orders, then changes the price on the items, this would cause incorrect data.
    – Mike
    May 24, 2017 at 17:28
  • It's not adding price of Custom options which are in Dropdown. Any Idea How can I get that too? Oct 18, 2017 at 8:09

You can retrieve them from the order item with following snippet

$options = $item->getProduct()

the options should be in $options['options']

  • 2
    this gives option details. does not give the price. Sep 1, 2015 at 9:33
  • hi Reena did you get the option price ? Oct 24, 2017 at 12:18

Your Answer

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

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