1

I need to display my custom option in.

app\design\adminhtml\default\default\template\sales\order\view\items\renderer\default.phtml

Database information:

Table Name : sales_flat_order_item

Row_name : product_options

value :

a:2:{s:15:"info_buyRequest";a:4:{s:4:"uenc";s:96:"aHR0cDovL2xvY2FsaG9zdC9wNi9kaWFtb25kcy9wcm9kdWN0L2FkZHRvY2FydC9wcm9kdWN0LzI5NzQ2L3NpemUvJTIwNy41";s:7:"product";s:5:"29746";s:8:"form_key";s:16:"pNUqrQJkKIWq5PTC";s:3:"qty";i:1;}s:9:"ring_size";s:11:"s:4:" 7.5";";}

"ring_size" is my custom option added while make order. Can you let me know How I can display it on admin order.

  • you can fetch options from item data. – Dhiren Vasoya Nov 17 '17 at 12:54
  • @DhirenVasoya Please read Question first. I need to display "ring_size". Am I clear? – Pratik Kamani Nov 20 '17 at 4:27
  • If you added it as custom options, then magento it seld display them in order. – Dhiren Vasoya Nov 20 '17 at 5:47
1

I was added "ring_size" as a custom option. I want to display it in admin->Sales->order. After search and implement a solution. I hope this will help to lot off people.

Frontend

\Testingorder\etc\config.xml

<checkout_cart_product_add_after> 
    <observers>
      <checkout_cart_product_add_after_handler> 
        <type>model</type> 
        <class>testingorder/observer</class> 
        <method>checkoutCartProductAddAfter</method> 
        <args></args> 
      </checkout_cart_product_add_after_handler>
    </observers>
</checkout_cart_product_add_after>

\Testingorder\Model\Observer.php

public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
{
    $item = $observer->getEvent()->getQuoteItem();
    $product = Mage::getModel('catalog/product')->load($item->getProductId());
    $ringSize = Mage::getModel('core/session')->getRingSize();
    if ($ringSize) {
        $item->addOption(array(
            "item_id" => $item->getId(),
            "product_id" => $item->getProduct()->getId(),
            "code" => "ring_size",
            "value" => serialize($ringSize)
        ));
        $item->save();
    }
}

Adminhtml

\app\design\adminhtml\default\default\template\sales\items\column\name.phtml

<?php if($custom_options = unserialize($_item->getproduct_options())):
    if($ring_size = unserialize($custom_options['ring_size'])): ?>
        <dl class="item-options">
            <dt><?php echo $this->helper('sales')->__('Ring Size') ?></dt>
            <dd><?php echo '<pre>';print_r($ring_size); ?></dd>
        </dl>
    <?php   endif;
endif; ?>

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.