Henk Rensenbrink
Henk Rensenbrink

Reputation: 87

Magento billing address

I am using the one page checkout module from AheadWorks and I am trying to only retrieve billing addresses from logged in members.

Currently the dropdown menu for choosing their address to bill from shows all addresses created by a logged in member. Also shipping adresses. I would like this to only show billingaddresses. Is there a way to do so? I already took a look inside the block which should be used, but unfortunately, I don't understand.

public function getAddressesHtmlSelect($type)
{
    if ($this->isCustomerLoggedIn()) {
        $options = array();
        foreach ($this->getCustomer()->getAddresses() as $address) {
            $options[] = array(
                'value' => $address->getId(),
                'label' => $address->format('oneline')
            );
        }

        $addressDetails = Mage::getSingleton('checkout/session')->getData('aw_onestepcheckout_form_values');
        if (isset($addressDetails[$type.'_address_id'])) {
            if (empty($addressDetails[$type.'_address_id'])) {
                $addressId = 0;
            } else {
                $addressId = $addressDetails[$type.'_address_id'];
            }
        } else {
            $addressId = $this->getQuote()->getBillingAddress()->getCustomerAddressId();
        }
        if (empty($addressId) && $addressId !== 0) {
            $address = $this->getCustomer()->getPrimaryBillingAddress();
            if ($address) {
                $addressId = $address->getId();
            }
        }

        $select = $this->getLayout()->createBlock('core/html_select')
            ->setName($type.'_address_id')
            ->setId($type.'-address-select')
            ->setClass('address-select')
            ->setValue($addressId)
            ->setOptions($options);

        return $select->getHtml();
    }
    return '';
}

Upvotes: 2

Views: 1332

Answers (2)

Oscar
Oscar

Reputation: 1

I was looking for this as well, here is something that I found, try it out: http://www.magebuzz.com/blog/disable-shipping-address-in-magento-checkout/

Upvotes: -1

Zefiryn
Zefiryn

Reputation: 2265

Simple answer is no, you can't do that. In principle magento has customer entity and customer address entity. Customer address can have type which is billing or shipping but this only applies for quote and order. But when the address is saved in customer addresses it has no indication which one it is so you can use it for both steps.

Long answer. To achieve what you need you would have to extend magento customer address entity and put this division inside the entity itself. This would however require to rewrite some portion of the code which is to broad to give exact answer here.

Alternatively you could try to determine if an address is billing or shipping by going through previous orders of the user and checking which type it was there.

Upvotes: 2

Related Questions