I have an extra field in my customer account registration where the customer can choose a US school from our database that they are affiliated with. We want to have the school address populated into the customer data when the customer account is created.

I have turned on address fields in customer account creation via the following xml in local.xml. I temporarily have the fields commented out in the register.phtml template. I am going to post the address this way, but if there is more than one address I would like to add to the customer account, how would I add more during the registration post?

        <reference name="customer_form_register">
            <action method="setShowAddressFields"><value>true</value></action>

Going to do an ajax call to obtain the school address then append the applicable values in the following hidden fields. Again, I will often need to post more than one address.

<?php if($this->getShowAddressFields()): ?>
        <input type="hidden" name="create_address" value="1" />
        <input type="hidden" name="company" id="company" value="" title="<?php echo $this->__('Company') ?>" />
        <input type="hidden" name="telephone" id="telephone" value="" title="<?php echo $this->__('Telephone') ?>" />
        <input type="hidden" name="street[]" value="" title="<?php echo $this->__('Street Address') ?>" id="street_1" />
        <input type="hidden" name="street[]" value="" title="<?php echo $this->__('Street Address 2') ?>" id="street_2" />
        <input type="hidden" name="city" value="" title="<?php echo $this->__('City') ?>" id="city" />
        <input type="hidden" id="region_customer_id" name="region_cait_id" title="<?php echo $this->__('State/Province') ?>">
        <input type="hidden" id="region" name="region" value="" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
        <input type="hidden" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
        <input type="hidden" name="default_billing" value="1" />
        <input type="hidden" name="default_shipping" value="1" />
    <?php endif; ?>

If I need to create a module instead: What event should I hook into? How do I save an address into customer data? I will need values posted on the customer account creation form.

  • Have you thought about using the customer attribute and tying into a dropdown on registration? Then the data would automatically be there. *Unless there are 100's of schools! Sep 24, 2013 at 20:11
  • I'm not sure what are you trying to accomplish. Take a look at this link, it might help excellencemagentoblog.com/…
    – Shathish
    Sep 25, 2013 at 4:58
  • No I don't want to add custom fields. I want the schools to be populated into the saved billing and shipping addresses for the customer, and yes, there can be like 50 for a "district purchaser" while many will just have one address for "school purchaser". Sep 26, 2013 at 18:42
  • 2
    May I ask why the school address would need to be duplicated into the customer record? Can't you just reference it by Address Id?
    – philwinkle
    Sep 26, 2013 at 19:49
  • 1
    @CaitlinHavener did you ever finish this? Fancy posting the answer? May 19, 2014 at 14:35


Browse other questions tagged or ask your own question.