Question

Im working on a magento store with two different types of gift message. If a customer chooses to create a gift message I need to be able to display it in the invoice. What would be the best way to approach this? Should I make a custom module or just copy the invoice/sales module in local and edit it? I'll obviously appreciate any help/answer but the less the answer assumes I know the better. Thanks in advance!!

Was it helpful?

Solution

Add an observer

        <sales_convert_quote_item_to_order_item>
            <observers>
                <my_observer>
                    <type>singleton</type>
                    <class>my_observer/observer</class>
                    <method>salesConvertQuoteItemToOrderItem</method>
                </my_observer>
            </observers>
        </my_observer>

and just add an custom option:

public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
{
    /* @var $quoteItem Mage_Sales_Model_Quote_Item */
    $quoteItem = $observer->getItem();
    /* @var $orderItem Mage_Sales_Model_Order_Item */
    $orderItem = $observer->getOrderItem();

    if (ITEM_HAS_GIFT_MESSAGE) {
        $options = $orderItem->getProductOptions();
        if (!isset($options['additional_options'])) {
            $options['additional_options'] = array();
        }
        $price = $helper->__('Price');
        $options['additional_options'][] = array(
            'label'       => '',
            'value'       => $message,
            'print_value' => $message,
        );
        $orderItem->setProductOptions($options);
    }
}

This is added to creditmemo, etc. too!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top