I have been asked to fix a form which should add a new (non-default) billing address to a customers account. The action of the form is empty and when submitted a billing.Save() function is executed.

In trying to work out what might be broken I have struggled to find an explanation as to how saving a new billing address for an existing customer works.

Could anyone point me to the where this is handled and how I would go about this from a form in the template/checkout/onepage/billing.phtml template file.


1 Answer 1


The model which handles the saving of the information entered in the billing section during checkout can be located at app/code/core/Mage/Checkout/Model/Type/Onepage.php.

You're looking for a public function named saveBilling($data, $customerAddressId).

During this step of checkout, Magento stores the information populated by the customer inside the quote object. In Magento 1.9.x, you'll see around line 306 of the Model file:

$address->setSaveInAddressBook(empty($data['save_in_address_book']) ? 0 : 1);

Which in turns stores the address information to the database.

You mention in your question that the information submitted seems to be empty, which is likely being caught right as the function commences:

if (empty($data)) {
    return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid data.'));

The data being submitted is somehow corrupted (this could be due to a JS error, third party extension etc.). I'd suggest disabling any third party extensions which interfere with the checkout process, one-by-one, to identify the culprit.

It would also be useful to check whether any JS errors are occurring on the page, which you can identify using the dev tools feature of whichever browser you are using.

  • Thanks for your help here. There are no JS errors so must be occuring elsewhere. I'll investigate further and update when I find the solution!
    – rushtoni88
    Commented Jul 21, 2017 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.