0

I have added custom option programmatically when product adding to the cart. Now I want to know how to view it from the back end after order placed.

Adding the custom option

$product = Mage::getModel('catalog/product')->load($productId);
$cart =  Mage::getSingleton('checkout/cart');
$param = array(
        'product' => $product->getId(),
        'qty' => $qty,
        'options' => array(
            123 => $imagePath  // Custom option with id: 123
        )
    );
    $request = new Varien_Object();
    $request->setData($param);
    $cart->addProduct($product, $request);

1 Answer 1

1

You can use below script to get custom options used in order.

$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'];
            }
        }
    }

Your Answer

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

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