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

attributescheckoutmagentoPHP

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.

Best Answer

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.