0

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!!

1

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!

  • hey, thanks for the answer. What files are you talking about here? I assumed it was all done in invoice.php and abstract.php – develophper Nov 18 '13 at 17:30
  • No, I'm talking about observers: magentocommerce.com/wiki/5_-modules_and_development/0-_module_development_in_magento/customizing_magento_using_event-observer_method – Fabian Blechschmidt Nov 18 '13 at 19:27

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.