2

I am using Enterprise, so I added some new Customer Address Attributes.

<?php $addressAttributes = $this->getChild('customer_form_billing_address_user_defined_attributes');?>
            <?php if ($addressAttributes): ?>
                <?php $addressAttributes->setEntity($this->getAddress())->setEntityType('customer_address');?>
                <?php $addressAttributes->setFieldIdFormat('billing:%1$s')->setFieldNameFormat('billing[%1$s]');?>
                <?php echo $addressAttributes->setExcludeFileAttributes(true)->setShowContainer(false)->toHtml()?>
            <?php endif;?>

This is the code from biling.phtml which renders my new fields. I was expecting that this would work by default..to save the data from form in database for my new fields. In sales_flat_order_address I don't see anything related to my fields. Am I missing something? Should I do something custom to save the fields and then to be displayed in view order order?

2

You have to create this entries in your module's config.xml:

<global>
    <fieldsets>
        <sales_convert_quote_address>
            <yourfield>
                <to_customer_address>*</to_customer_address>
                <to_order_address>*</to_order_address>
            </yourfield>
        </sales_convert_quote_address>
        <customer_address>
            <yourfield>
                <to_quote_address>*</to_quote_address>
            </yourfield>
        </customer_address>
    </fieldsets>
</global>

and the tables in database manually or via install script:

$sales_flat_quote_address = $this->getTable('sales/quote_address');
$installer->run("ALTER TABLE $sales_flat_quote_address ADD `yourfield` varchar(255) NOT NULL");

$sales_flat_order_address = $this->getTable('sales/order_address');
$installer->run("ALTER TABLE $sales_flat_order_address ADD `yourfield` varchar(255) NOT NULL");

and then CLEAR CACHES!!!

1

Firstly you will need to add the attribute to the tables that store the quote and order addresses. This can be done via a setup script.

Then you will need to deal with the address conversion so that when you place the order you will take that attributes from the quote address and add them to the order and customer address that are created.

<sales_convert_quote_address>
    <your_attribute>
        <to_order_address>*</to_order_address>
        <to_customer_address>*</to_customer_address>
    </your_attribute>
</sales_convert_quote_address>

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.