0
votes

I have created couple of custom fields in Magento's customer addresses using a tutorial available here.

When a customer edits his/her address the fields are shown, when he is checking out through the one page checkout being logged in, the addresses appear as a drop down. In this case the address is hidden from the client using a display:none; style.

The problem is that the custom address attributes are not available but the regular attributes are available.

What I think is that when the customer is editing the address, the controller is customer and when he is on onepage the controller is checkout. There is some error or I am missing something so that the onepage controller fails to pull custom address fields.

What I have done:

I have overridden the billing.phtml file in

 /app/design/frontend/base/default/template/checkout/onepage

The fields show up in the onepage checkout billing section. But when the system is loading a default address the fields values are not loaded like other values get loaded. For example, the phone number is loaded by calling the function

$this->getAddress()->getTelephone();

but when i call my custom field whose name is address_mobile like

$this->getAddress()->getAddressMobile();

The system can not pull the value, like it pulls for telephone. Below is the source code of how the field appears in hidden section.

Html Code

1

1 Answers

0
votes

The one step checkout does not look for any custom fields.

If you look in app / design / frontend / base / default / template / persistent / checkout / onepage / Billing.phtml

In this instance were looking at the billing address that can be changed you can also do the same for shipping if required.

What you will need to do is update the template file above ( Ideally moving it to your package under app design frontend ). This will be showing the new form fields on the checkout but it wont actually persist to the database. In order to save these values to the database you are going to need to override the OnePageController.php and the saveBilling / saveShipping methods to store your data.

If you need any more help on this let me know and I will look to find an example that you can use.