How to add custom field to order in Magento?

后端 未结 1 448
陌清茗
陌清茗 2021-02-09 10:19

I want to add one new custom field to one page checkout in Magento. I have created a module with installer:

$installer = $this;
$installer->startSetup();
$set         


        
1条回答
  •  遥遥无期
    2021-02-09 11:16

    Add an observer :

    
        
            
                
                    singleton
                    mymodule/observer
                    Savefield
                
            
        
    
    

    And in the mymodule/savefield/model/obsever.php file add this:

    class Mymodule_Savefield_Model_Observer
    {
        public function Savefield($observer){
            //get event data
            $event = $observer->getEvent();
    
            //get order
            $order = $event->getOrder();
    
            //set the variable here
            $order->setMyField($fieldVal);
        }   
    }
    

    0 讨论(0)
提交回复
热议问题