1

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.

  • are you saying that customer with the old address form aren't able to proceed through checkout? – Julien Lachal Nov 12 '15 at 13:38
  • Yes Currently I have modified the Address validation to consider the new address line also – ted Nov 12 '15 at 19:18
1

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.

| improve this answer | |
  • This will hide the pre stored address, But I dont want customers to re write whole adress just for this particular street line. What i needed was user select a pre stored address -> Some validation (Protoype validation) -> Then open the pre stored address in the edit form. – ted Nov 13 '15 at 6:26
  • the whole address will be pre-filled with the previous value so customer does not have to rewrite them. Anyway if you want you can show only the missing field or you can design a whole new form (use type hidden for the old pre-compiled fields to have them saved). To do what you describe in the comment you need a strong customization of the billing form including a custom controller to save the address data and reload the full compiled address int the billing form. It's a sort of two step address filling form. – Giuseppe Nov 13 '15 at 8:19
  • When an address (There is more than 2 address ) is selected the whole address is not prefilled with selected address. Form is filled with some address, But not the selected address (I think the default billing address). Is some JS tweeks will be ok to fix this ?. In billing.save() or some other function verify the address fields. – ted Nov 16 '15 at 7:55
  • Check using i.e. FireBug what's happen when you select another address and adapt to the way magento use. But If it changes the address by js it should do an ajax call to get and fill the appropriate fields. – Giuseppe Nov 16 '15 at 10:22
  • I confirmed the data send (billing_address_id is send while selecting pre stored address and other address fields with default address values) with chrome dev tools, OK thanks for the point. I might not pre fill everything will just ask the customer to fill the new street line (popup or something) only and do a save address. – ted Nov 16 '15 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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