1

I am trying to fill in the field: Company, when adding a new address, retrieving the company name from the current address.

I am editing: /www.vadotex.biz/web/app/design/frontend/vadotex/default/template/customer/address/edit.phtml

and have tried:

<?php echo $this->htmlEscape($this->getCustomer()->getShippingAddress()->getCompany()) ?>

and

<?php echo $this->htmlEscape($this->getCustomer()->getAddresses()->getCompany()) ?>

as value of the field.

I want it to copy the company name of the current shipping address, but when using above codes, it wont show me any value, and just cuts off the form.

2 Answers 2

4

Try ->getPrimaryShippingAddress() or ->getPrimaryBillingAddress() on the getCustomer() and use ->getCompany()` for the data

1

In that block (Mage_Customer_Block_Address_Edit), you need to do $this->getAddress()->getCompany().

If you do $this->getCustomer(), you're getting the customer object, from which you can get addresses a well, but getAddresses() or getShippingAddress() are not valid methods of the customer object. See Mage_Customer_Model_Customer you want to retrieve addresses from this object.

1
  • I have tried your answer, but this gives me no value in the field, while i do have the company name filled in my current address.
    – John
    Commented Mar 17, 2015 at 22:47

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.