3

At magento checkout, when the user has already got registered address, it comes with a select to choose between the registered address or choose a new address.

How would I change this so that when the checkout was loaded, regardless of whether the client has a registered address or not, the "new address" was checked and the fields opened for typing?

3 Answers 3

0

Add ->setValue('your value') to your select generation. You can set here option New Address.

5
  • This code returns me error 500 on the console. Sep 18, 2017 at 16:12
  • show me your code Sep 18, 2017 at 16:44
  • I use the code that is in billing.phtml Sep 18, 2017 at 17:20
  • please copy your code (where select is generated) and paste here Sep 18, 2017 at 17:22
  • From this code that is located in the file billing.phtml, the magento "mounts" the select where you have the option to choose the address already registered, or choose to send in a new address: <label for="billing-address-select"><?php echo $this->__('Select a shipping address from your address book or enter a new address.') ?></label><div class="input-box"><?php echo $this->getAddressesHtmlSelect('billing') ?></div> Sep 18, 2017 at 17:26
0

Do the following changes in your billing.phtml file located here

app\design\frontend\YourPackage\YourTheme\template\checkout\onepage\billing.phtml

Your Default Code:

<form id="co-billing-form" action="">
<fieldset>
    <ul class="form-list">
    <?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; ?>>
        <fieldset>
            <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />

Updated Code:

<form id="co-billing-form" action="">
<fieldset>
    <ul class="form-list">
    <?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 $addressId = $this->getAddress()->getCustomerAddressId();?>
                <?php (empty($addressId)) ? $this->getAddress()->getCustomerAddressId(0) : '' ?>
                <?php echo $this->getAddressesHtmlSelect('billing') ?>
            </div>
        </li>
    <?php endif; ?>
    <li id="billing-new-address-form"<?php if ($this->customerHasAddresses() && !empty($addressId)): ?> style="display:none;"<?php endif; ?>>
        <fieldset>
            <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />

Make same changes for the Shipping address on checkout page

app\design\frontend\YourPackage\YourTheme\template\checkout\onepage\shipping.phtml

1
  • It did not work with your code. Sep 18, 2017 at 16:19
0

I solved this question by making it possible for only the user to register a new address and not being able to select what he registered the following way:

In the app \ design \ frontend \ YourPackage \ YourTheme \ template \ checkout \ onepage \ billing.phtml file comment the following code:

<div class="input-box">
   <?php //echo $this->getAddressesHtmlSelect('billing') ?>
</div>

A little further down, in the ul, comment the display: none so that the fields already appear in the page load.

Original Code:

<ul id="onestepcheckout-billing-address-list"<?php if ($this->customerHasAddresses()): ?> style="overflow: hidden;height: 0px;display:none"<?php endif; ?>>

Code changed:

<ul id="onestepcheckout-billing-address-list"<?php if ($this->customerHasAddresses()): ?> style="overflow: hidden;height: 100%;/*display:none*/"<?php endif; ?>>

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.