1

I want to add data in cart enter image description here

How can i do this without change core files

1 Answer 1

2

You can do it by Observer.
1.You need to add Following Event in Config.xml

<sales_quote_collect_totals_before>
<observers>
<hackathon_presentation>
<type>singleton</type>
<class>modulename/observer</class>
<method>salesQuoteAddressCollectTotalsBefore</method>
</hackathon_presentation>
</observers>
</sales_quote_collect_totals_before>

**In Observer.php add below mentioned code **

 public function salesQuoteAddressCollectTotalsBefore($observer)
    {
        $quote = $observer->getQuote();
        $quote_items = $quote->getItemsCollection();
        foreach ($quote_items as $item) {
            $additionalOptions = array(
                array(
                    'code'  => 'my_code',
                    'label' => 'This text is displayed through additional options',
                    'value' => 'ID is ' . $item->getProductId() . ' and SKU is ' . $item->getSku()
                )
            );
            $item->addOption(
                array(
                     'code'  => 'additional_options',
                     'value' => serialize($additionalOptions),
                )
            );
        }
    }

For More see Here and Here

0

Your Answer

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

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