air4x
air4x

Reputation: 5683

Magento - Custom attribute in customer address, not copied to sales_flat_order_address and sales_flat_quote_address on checkout

I have created a new attribute ‘county’ in customer address. It is working fine and I am able to save values in this field from the frontend.

I want this field available in address of orders. So I have added a column ‘county’ in the tables

‘sales_flat_quote_address’ and ‘sales_flat_order_address’

Then I have modified Sales/etc/config.xml to include this field in fieldsets. I have added entries for this field in

sales_copy_order_billing_address,
sales_copy_order_shipping_address,
sales_convert_quote_address,
sales_convert_order_address,
customer_address

But when I do onepage checkout, the value in this field is not copied to the address in orders. I am selecting an existing address with value in this field during checkout for billing and shipping address.

Right now, I have not edited any template file in checkout to include this field. But as I am selecting an existing address, this shouldn’t be causing the problem, right ?

I am using magento 1.5.1.0. While I know php well, I am kind of a newbie in magento.

I have checked the question Magento: save custom address attribute in checkout and have done everything as given in the answer.

Have I missed out something. If so, please provide your suggestion. Thanks.

Upvotes: 1

Views: 6485

Answers (5)

Ricardo Martins
Ricardo Martins

Reputation: 6003

Try this in one of your module's config.xml file...

<global>
...
    <fieldsets>
        <customer_address>
            <county>
                <to_quote_address>*</to_quote_address>
                <to_order_address>*</to_order_address>
            </county>
         </customer_address>
    </fieldsets>
...
</global>

Make sure you have created county field in both tables (sales_flat_quote_address and sales_flat_order_address).

Upvotes: 2

Naveenbos
Naveenbos

Reputation: 2562

I have tried this, and it is worked for me, please add this xml code to our module config.xml file

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

Upvotes: 2

ShaunOReilly
ShaunOReilly

Reputation: 2206

Have you checked out the Config.xml in Sales/etc, and looked at the "sales_copy_order_billing_address" sections.

This defines which column gets copied over from table1 to "mapped columns" in table2.

So, add County to the list, wherever the data gets copied over for Shipping Address, and Billing address.

That XML mapping gets used when code like the following, gets executed:

Mage::helper('core')->copyFieldset('customer_address', 'to_quote_address', $address, $this);

The first parameter is the "from table column" node mapping, and the second parameter is the "to table column" mapping.

Hope this works.

Upvotes: 2

air4x
air4x

Reputation: 5683

I have got it working. I did not have to add anything else.

The problem was that, I had copied config.xml from app/code/core/Mage/Sales/etc to app/code/local/Mage/Sales/etc and made my changes in the new one.

When I made the changes in the original config.xml file itself and tested, the custom field value was copied to the order address on checkout.

Thanks.

Upvotes: 0

Zifius
Zifius

Reputation: 1650

Have you cleared / disabled cache as well? Also do not modify core config files, better create module and extend fieldsets with your own

Upvotes: 0

Related Questions