I am editing this: app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php

getItemPricesForDisplay() and getItemOptions() are of my interest

public function getItemPricesForDisplay()
    $order = $this->getOrder();
    $item  = $this->getItem();
    if (Mage::helper('tax')->displaySalesBothPrices()) {
        $prices = array(
                'label'    => Mage::helper('tax')->__('Excl. Tax') . ':',
                'price'    => $order->formatPriceTxt($item->getPrice()),
                'subtotal' => $order->formatPriceTxt($item->getRowTotal())
                'label'    => Mage::helper('tax')->__('Incl. Tax') . ':',
                'price'    => $order->formatPriceTxt($item->getPriceInclTax()),
                'subtotal' => $order->formatPriceTxt($item->getRowTotalInclTax())
    } elseif (Mage::helper('tax')->displaySalesPriceInclTax()) {
        $prices = array(array(
            'price' => $order->formatPriceTxt($item->getPriceInclTax()),
            'subtotal' => $order->formatPriceTxt($item->getRowTotalInclTax()),
    } else {
        $prices = array(array(
            'price' => $order->formatPriceTxt($item->getPrice()),
            'subtotal' => $order->formatPriceTxt($item->getRowTotal()),
    //@modtom: overwrite prices
    $prices = "";     

    return $prices;

 * Retrieve item options
 * @return array
public function getItemOptions() {
    $result = array();
    if ($options = $this->getItem()->getOrderItem()->getProductOptions()) {

        if (isset($options['options'])) {
            $result = array_merge($result, $options['options']);
        if (isset($options['additional_options'])) {
            $result = array_merge($result, $options['additional_options']);
        if (isset($options['attributes_info'])) {
            $result = array_merge($result, $options['attributes_info']);

    return $result;

I need to get the price of a custom option and subtract it from the price stored in the $prices[0][price] array e.g. $prices[0][price] = $prices[0][price] - (price of a custom option);

How can I get a price of a custom option inside this function from this level of Magento?

I would probably have to somehow get the array with all the possible custom options for this item, then compare them with the one that was selected and take the price out of the array? Could you give me any tips on how to do it in Magento? How to get the array that includes the cost of the custom option?

1 Answer 1


Better would be write around plugin for this method instead of changing sources. And then you can add any dependency to constructor of your plugin.

You can use Magento2 Samples as guideline: https://github.com/magento/magento2-samples/tree/master/sample-module-interception

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.