0

On checkout, I'd like the Billing section to load - by default - the last (saved) address that the customer checked out with by default, as opposed to the primary billing address.

I looked at app/design/frontend/base/default/template/checkout/onepage/billing.phtml:

And established that this is the call I'll need to override:

<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>

This method (getAddressesHtmlSelect('billin')) is located in:

app/code/core/Mage/Checkout/Block/Onepage/Abstract.php: (~line 110)

At about line 124, the $type parameter is verified:

if ($type=='billing') {
    $address = $this->getCustomer()->getPrimaryBillingAddress();
}

I'm trying to think of an intelligible method to, instead of loading the primary billing address, loading the last billing address which was used?

Or do you think the better approach would be saving the billing address used on checkout as the primary billing address?

I suppopse either method would work, but would appreciate some insight.

P.S. I couldn't find a setPrimaryBillingAddress method anywhere in the code base.

2 Answers 2

1

You should not overwrite the primary Billing Adress, since the customer won't expect that to happen and might not check the address next time he orders.

You might be able to access the last used billing address by using the order model collection filtered by customer and sorted by date or something.

p.s. lacking the reputation to comment, this is an answer instead

p.p.s. setPrimaryBillingAddress is a magic setting function. It is no definited but does something like `set(primary_billing_address)' where primary_billing_address is an attribute/table column

0

This approach is not recommended though but still if you want to achieve this, you can use cookies to store billing address, as long as cookies exist, the last entered address will be there. Simple approach. I have also used cookies for guest checkout.

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.