Magento – way to edit the pre stored address in the Onepage checkout page

addressbilling-addresscheckoutonepage-checkout

My issues, After launching the website I have made some of the street lines mandatory, which was not initially. So some of the customers already have address stored without the new mandatory street line. So is there a Magento way to show the selected stored address in the Onepage adress form and customer can edit it and save it(Save in same ID) and continue with Checkout.

Best Answer

I can suggest the following:

in billing.phtml Magento do a check in order to show you the address fields if you have no addresses already stored, or to show you the select filled with your addresses.

<?php if ($this->customerHasAddresses()): ?>
    <li class="wide">
        <label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
        <div class="input-box">
            <?php echo $this->getAddressesHtmlSelect('billing') ?>
        </div>
    </li>
<?php endif; ?>
<li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>

As you can see Magento always prepare and populate the address's field but the form will be "hidden".

You can write a function that look into the saved address for the missing new mandatory fields and add this function to the if

<?php if ($this->customerHasAddresses() && $this->allNewFieldsAreCompiled()): ?>
    <li class="wide">
        <label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
        <div class="input-box">
            <?php echo $this->getAddressesHtmlSelect('billing') ?>
        </div>
    </li>
<?php endif; ?>
<li id="billing-new-address-form"<?php if ($this->customerHasAddresses()  && $this->allNewFieldsAreCompiled()): ?> style="display:none;"<?php endif; ?>> 

I hope this will help you.