{"id":549,"date":"2019-08-13T07:11:12","date_gmt":"2019-08-13T07:11:12","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/08\/13\/add-additional-options-in-magento\/"},"modified":"2025-05-22T16:10:04","modified_gmt":"2025-05-22T10:40:04","slug":"add-additional-options-in-magento","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-additional-options-in-magento\/","title":{"rendered":"How to Add Additional Options in Magento"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Similar to my solution to <a href=\"https:\/\/meetanshi.com\/blog\/add-additional-options-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">add additional options in Magento 2<\/a>, I have come up with the code for Magento 1 in this post.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Magento 1 store, owing to the limitations of the platform, may require customization to offer excellent features. Hence, the method to <em><strong>add additional options in Magento<\/strong><\/em>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We know that making changes in the core functionalities is not a good practice. Therefore follow the below method to custom develop features that allow collecting customer details, implement out-of-box functionalities and improve the shopping experience!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can dynamically add options based on specific products without adding them from the backend using this method! You can also <a href=\"https:\/\/meetanshi.com\/blog\/dynamically-add-link-to-customer-account-navigation-in-magento-2\/\">dynamically add customer account navigation in Magento 2<\/a> it allows you to customize and enhance the customer\u2019s account dashboard by adding custom links or sections based on specific business needs and requirements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Add Additional Options in Magento:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create <strong>config.xml<\/strong> file at <strong>app\/code\/local\/Vendor\/Extension\/etc\/<\/strong> folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&lt;config>\n    &lt;modules>\n        &lt;Vendor_Extension>\n            &lt;version>1.0.0&lt;\/version>\n        &lt;\/Vendor_Extension>\n    &lt;\/modules>\n    &lt;global>\n        &lt;models>\n            &lt;extension>\n                &lt;class>Vendor_Extension_Model&lt;\/class>\n            &lt;\/extension>\n        &lt;\/models>\n        &lt;events>\n            &lt;checkout_cart_product_add_after>\n                &lt;observers>\n                    &lt;Vendor_Extension_Model_Observer>\n                        &lt;type>singleton&lt;\/type>\n                        &lt;class>Vendor_Extension_Model_Observer&lt;\/class>\n                        &lt;method>checkout_cart_product_add_after&lt;\/method>\n                    &lt;\/Vendor_Extension_Model_Observer>\n                &lt;\/observers>\n            &lt;\/checkout_cart_product_add_after>\n\n            &lt;sales_model_service_quote_submit_before>\n                &lt;observers>\n                    &lt;Vendor_Extension_Model_Observer_Set_Order>\n                        &lt;type>singleton&lt;\/type>\n                        &lt;class>Vendor_Extension_Model_Observer&lt;\/class>\n                        &lt;method>setAdditionalDataToOrder&lt;\/method>\n                    &lt;\/Vendor_Extension_Model_Observer_Set_Order>\n                &lt;\/observers>\n            &lt;\/sales_model_service_quote_submit_before>\n        &lt;\/events>\n    &lt;\/global>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create <strong>Observer.php<\/strong> file at <strong>app\/code\/local\/Vendor\/Extension\/Model\/<\/strong> folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nclass Vendor_Extension_Model_Observer\n{\n    public function checkout_cart_product_add_after($observer)\n    {\n        $event = $observer->getEvent();\n        $quoteItem = $event->getQuoteItem();\n\n        $messageOption = array(\n            'label' => 'Message',\n            'option_value' => 'Custom Value',\n            'value' => 'Custom Value',\n            'print_value' => 'Custom Value',\n        );\n\n        $value = array('message' => $messageOption);\n        $value = serialize($value);\n        $quoteItem->addOption(array('code' => 'additional_options', 'product_id' => $quoteItem->getProductId(), 'value' => $value));\n    }\n\n    public function setAdditionalDataToOrder($observer)\n    {\n        try {\n            $quote = $observer->getEvent()->getQuote();\n            $order = $observer->getEvent()->getOrder();\n            $quoteItems = [];\n\n            foreach ($quote->getAllVisibleItems() as $quoteItem) {\n                $quoteItems[$quoteItem->getId()] = $quoteItem;\n            }\n\n            foreach ($order->getAllVisibleItems() as $orderItem) {\n\n                $quoteItemId = $orderItem->getQuoteItemId();\n                $quoteItem = $quoteItems[$quoteItemId];\n\n                $additionalOptions = $quoteItem->getOptionByCode('additional_options');\n\n                if (count($additionalOptions) > 0) {\n                    $options = $orderItem->getProductOptions();\n                    $options['additional_options'] = unserialize($additionalOptions->getValue());\n                    $orderItem->setProductOptions($options);\n                }\n\n            }\n        } catch (\\Exception $e) {\n            Mage::log($e->getMessage());\n        }\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I\u2019d be very grateful if you helped share this helpful post on social media to fellow developers!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Similar to my solution to add additional options in Magento 2, I have come up with the code for Magento 1 in this post. The&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-549","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=549"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":15311,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/549\/revisions\/15311"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}