{"id":427,"date":"2019-05-21T12:54:01","date_gmt":"2019-05-21T12:54:01","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/05\/21\/add-new-column-in-magento-2-quote-table-order-table\/"},"modified":"2025-05-22T16:51:02","modified_gmt":"2025-05-22T11:21:02","slug":"add-new-column-in-magento-2-quote-table-order-table","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-new-column-in-magento-2-quote-table-order-table\/","title":{"rendered":"How to Add New Column in Magento 2 Quote Table &#038; Order Table"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2, no matter how feature-rich, falls short when it comes to meeting the highly customized requirements of clients. Fortunately, the flexible platform allows the developers to modify the code in order to complete the clients&#8217; requirements!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, the customization that I&#8217;m discussing is to <i><strong>add new column in Magento 2 Quote table &amp; Order table<\/strong><\/i>. It can be any column that is not in the default Magento 2 quote table and order table, but the data from the database is needed to be fetched in these tables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Follow the below method and you get customized Magento 2 quote table and order table!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Add New Column in Magento 2 Quote Table &amp; Order Table:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create file <strong>UpgradeSchema<\/strong> at <i><strong>Vendor\/Extension\/Setup<\/strong><\/i><\/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\nnamespace Vendor\/Extension\/Setup;\nuse Magento\\Framework\\Setup\\UpgradeSchemaInterface;\nuse Magento\\Framework\\Setup\\SchemaSetupInterface;\nuse Magento\\Framework\\Setup\\ModuleContextInterface;\nclass UpgradeSchema implements UpgradeSchemaInterface\n{\n    public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)\n    {\n        $setup->startSetup();\n        $quoteTable = 'quote';\n        $orderTable = 'sales_order';\n        \/\/Quote table   \n        $setup->getConnection()\n            ->addColumn(\n                $setup->getTable($quoteTable),\n                'fee',\n                [\n                    'type' => \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_DECIMAL,\n                    'length' => '12,4',\n                    'default' => 0.00,\n                    'nullable' => true,\n                    'comment' => 'Extra fee'\n                ]\n            );\n        \/\/Order table\n        $setup->getConnection()\n            ->addColumn(\n                $setup->getTable($orderTable),\n                'fee',\n                [\n                    'type' => \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_DECIMAL,\n                    'length' => '12,4',\n                    'default' => 0.00,\n                    'nullable' => true,\n                    'comment' => 'Extra fee'\n                ]\n            );\n        $setup->endSetup();\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Hopefully, you find the solution in the above method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2, no matter how feature-rich, falls short when it comes to meeting the highly customized requirements of clients. Fortunately, the flexible platform allows 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-427","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/427","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=427"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"predecessor-version":[{"id":15420,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/427\/revisions\/15420"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}