1

I have created custom address field using below code in my module--

   $installer = $this;

$installer->startSetup();

$setup = $this;

$entityTypeId = $setup->getEntityTypeId('customer_address');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$this->addAttribute('customer_address', 'delivery_premises_type', array(
    'type' => 'int',
    'input' => 'select',
    "backend" => "",
    'label' => 'Delivery Premises Type',
    "source" => "",
    'visible' => 1,
    'required' => 0,
    'user_defined' => 1,
    'default' => '',
    'visible_on_front' => 1,
    "frontend" => "",
    "unique" => false,
    'source' => 'address/entity_dpt',
));

$attribute = Mage::getSingleton("eav/config")->getAttribute("customer_address", "delivery_premises_type");
$setup->addAttributeToGroup(
        $entityTypeId, $attributeSetId, $attributeGroupId, 'delivery_premises_type', '999'  //sort_order
);


$used_in_forms=array(
                     'customer_address_edit',
                     'adminhtml_customer_address',
                     );

$attribute->setData("used_in_forms", $used_in_forms)
        ->setData("is_used_for_customer_segment", true)
        ->setData("is_system", 0)
        ->setData("is_user_defined", 1)
        ->setData("is_visible", 1)
        ->setData("sort_order", 100)
;
$attribute->save();



$sales_quote_address = $installer->getTable('sales/quote_address');
$installer->getConnection()
        ->addColumn($sales_quote_address, 'delivery_premises_type', array(
            'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
            'comment' => 'New Delivery Premises Type Field Added'
        ));

$sales_order_address = $installer->getTable('sales/order_address');
$installer->getConnection()
        ->addColumn($sales_order_address, 'delivery_premises_type', array(
            'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
            'comment' => 'New Delivery Premises Type Field Added'
        ));



$installer->endSetup();

and also changed in Configuration > customer Configuration > address template , I followed below links--

https://indiestechtips.wordpress.com/2011/07/30/how-to-add-custom-field-in-the-billing-and-shipping-address-of-onepage-checkout-in-magento/

https://raghunathgurjar.wordpress.com/2014/04/04/how-add-a-new-custom-field-to-customer-address/

still its not showing in sales order view page and in pdf as well.

Please help.

EDITS-

Here is config.xml

<fieldsets>
            <sales_convert_quote_address>
                <delivery_premises_type>
                    <to_order_address>*</to_order_address>
                    <to_customer_address>*</to_customer_address>
                </delivery_premises_type>
            </sales_convert_quote_address>
            <customer_address>
                <delivery_premises_type>
                    <to_quote_address>*</to_quote_address>
                </delivery_premises_type>
            </customer_address>
        </fieldsets>

I checked tables 'sales_flat_quote_address' and 'sales_flat_order_address', there is column 'delivery_premises_type but no values is saving in this column in both tables, if I do manual entry in this column in both tables, it works fine. why entry is not going in both tables.

SOLVED--- I did mistake in billing.phtml file during putting my custom field on checkout page.

1 Answer 1

0

In your module config.xml you have to write address conversion xml like :

<global>
    <fieldsets>
        <sales_convert_quote_address>
            <custom_address>
                <to_order_address>*</to_order_address>
            </custom_address>
        </sales_convert_quote_address>
    </fieldsets>
</global>
1
  • Please check edits
    – Shashank
    Feb 10, 2017 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.