I had to create a similar field (in this case, for this) for the corporate client, so here is how it turned out:
First, I created a module that would have all this fun. I added my own object installation record for the client, so I would not have to rely on the default client or rewrite any models unnecessarily (over time, you begin to conflict with yourself when overwriting). Your entity code seems to work, so it is up to you if you want to reorganize it.
Then I added a field to the client fields, which seem to help Magento understand what data needs to be stored in the database:
<global> <fieldsets> <customer_account> <referred_by> <create>1</create> <update>0</update> <to_order>customer_referred_by</to_order> </referred_by> </customer_account> </fieldsets> </global>
Then I added the field to the client form, just as you did above. During the verification process, I was forced to add a redefining model to one page in order to save data during the verification (in my case, only during invoicing):
class Company_Module_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage { public function saveBilling($data, $customerAddressId) { if (isset($data['referred_by'])) { // set referred for later use. $session = Mage::getSingleton("customer/session"); $session->setData("referred_by", $data['referred_by']); } return parent::saveBilling($data, $customerAddressId); }//end saveBilling }
and
<global> <models> <checkout> <rewrite> <type_onepage>Company_Module_Model_Checkout_Type_Onepage</type_onepage> </rewrite> </checkout> </models> </global>
After that, the data was saved correctly in the database. Hooray!
Hope this helps! Thanks Joe
source share