2

Is it possible to show billing and shipping fields in register page?

  • Bro possible nenga ena theme use panaringa – Ramesh S Oct 6 '17 at 10:33
  • Rwd theme bro... – Ranganathan Oct 6 '17 at 10:36
  • U want to show Address, Country, State, ect.. right? – Ramesh S Oct 6 '17 at 10:37
  • yes........pls help me to show bro... – Ranganathan Oct 6 '17 at 10:38
2

Step:1

/app/design/frontend/base/default/template/customer/form/register.phtml

Step:2

Find

<?php if($this->getShowAddressFields()): ?>

Just before add following line

<?php $this->setShowAddressFields(true) ?>

Step:3

This following change as like as below

<?php $this->setShowAddressFields(true) ?>

<?php if($this->getShowAddressFields()): ?>

or

/app/design/frontend/[your_package]/[your_theme]/layout/local.xml

<customer_account_create>
    <reference name="customer_form_register">
        <action method="setData"><key>show_address_fields</key><value>1</value></action>
    </reference>
</customer_account_create>
  • ithu illa bro......Billing address show aguthu,,,,,shipping address fields add pani database la save pananum.... – Ranganathan Oct 6 '17 at 10:47
  • enoda or answer try pannunga athu correct one – Ramesh S Oct 6 '17 at 10:48
  • bro nenga CBE enga irukinga and enga work panaringa – Ramesh S Oct 6 '17 at 10:49
  • bro ungaluku 50 Reputation kuduthuruka – Ramesh S Oct 6 '17 at 10:57
  • chat.stackexchange.com/users/267985/ramesh-s intha link la chat panunga – Ramesh S Oct 6 '17 at 10:58
0

I have Created an observer file of event <customer_register_success>

config.xml is

<?xml version="1.0"?>
    <config>
        <modules>
            <Vendor_Moduel>
                <version>0.1.0</version>
            </Vendor_Module>
        </modules>
        <frontend>
            <events>
                <customer_register_success> 
                    <observers>
                        <shipping>
                            <type>singleton</type>
                            <class>Vendor_Module_Model_Observer</class>
                            <method>shipping_field</method>
                        </shipping>
                    </observers>
                </customer_register_success>
            </events>
        </frontend>
    </config> 

And the Observer file is

class <Vendor>_<Module>_Model_Observer extends Mage_Customer_AccountController
{
    public function shipping_field(Varien_Event_Observer $observer)
    {
        if(Mage::app()->getRequest()->getPost('create_shipping_address')){
            $shippingAddress = Mage::getModel('customer/address');
            $shippingAddressForm = Mage::getModel('customer/form');
            $shippingAddressForm->setFormCode('customer_register_address')->setEntity($shippingAddress);

            $shippingAddressData = array(
                    'firstname'  => Mage::app()->getRequest()->getPost('firstname'),
                    'lastname'   => Mage::app()->getRequest()->getPost('lastname'),
                    'company'    => Mage::app()->getRequest()->getPost('shipping_company'),
                    'street'     => Mage::app()->getRequest()->getPost('shipping_street'),
                    'city'       => Mage::app()->getRequest()->getPost('shipping_city'),
                    'country_id' => Mage::app()->getRequest()->getPost('shipping_country_id'),
                    'telephone'  => Mage::app()->getRequest()->getPost('telephone'),
                    'region_id'  => Mage::app()->getRequest()->getPost('shipping_region_id'),
                    'postcode'   => Mage::app()->getRequest()->getPost('shipping_postcode')
                );

            $shippingAddressErrors = $shippingAddressForm->validateData($shippingAddressData);

            if($shippingAddressErrors === true){
                $shippingAddress->setId(null)
                                ->setIsDefaultBilling(Mage::app()->getRequest()->getPost('shipping_default_billing', false))
                                ->setIsDefaultShipping(Mage::app()->getRequest()->getPost('shipping_default_shipping', false));

                $shippingAddressForm->compactData($shippingAddressData);
                $customer = $this->_getCustomer();
                $customer->addAddress($shippingAddress);

                $shippingAddressErrors = $shippingAddress->validate();

                if (is_array($shippingAddressErrors)) {
                    $errors = array_merge($errors, $shippingAddressErrors);
                }
            }else{
                $errors = array_merge($errors, $shippingAddressErrors);
            }
        }
    }
}


register.phtml file add below shipping fields

<div id="shipping_address_fields" class="fieldset">
                <input type="hidden" name="create_shipping_address" value="1" />
                <div class="form-top-title">
                    <h2 class="legend"><?php echo $this->__('Shipping Address Information') ?></h2>
                </div>                          
                <div>
                    <ul class="form-list">
                        <li class="fields">
                            <div class="field" id="shipping_businessName">
                                <label for="shipping_company" class="required"><?php echo $this->__('Company') ?> <em>*</em></label>
                                <div class="input-box">
                                    <input type="text" name="shipping_company" id="shipping_company" value="<?php echo $this->htmlEscape($this->getFormData()->getShippingCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text required-entry" />
                                </div>
                            </div>
                        </li>
                        <li class="wide register-70">
                            <label for="shipping_street_1" class="required"><?php echo $this->__('Road') ?> <em>*</em></label>
                            <div class="input-box" style="clear: both;">
                                <input type="text" name="shipping_street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getShippingStreet(1)) ?>" title="<?php echo $this->__('Road') ?>" id="shipping_street_1" class="input-text required-entry" />
                            </div>
                        </li>
                        <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
                            <li class="wide register-30">
                                <div class="field">
                                    <label for="street_1" class="required"><em>*</em><?php echo $this->__('No') ?>.</label>
                                    <div class="input-box">
                                        <input type="text" name="shipping_street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getShippingStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="shipping_street_<?php echo $_i?>" class="input-text" />
                                    </div>
                                </div>
                            </li>
                            <li class="field  register-40">
                                <div class="field">
                                    <label for="shipping_zip" class="required"><?php echo $this->__('Postcode') ?> <em>*</em></label>
                                    <div class="input-box">
                                        <input type="text" name="shipping_postcode" value="<?php echo $this->htmlEscape($this->getFormData()->getShippingPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="shipping_zip" class="input-text validate-zip-international required-entry" />
                                    </div>
                                </div>
                            </li>
                        <?php endfor ?>
                        <li class="fields register-60">
                            <div class="field">
                                <label for="shipping_city" class="required"><?php echo $this->__('Place') ?> <em>*</em></label>
                                <div class="input-box">
                                    <input type="text" name="shipping_city" value="<?php echo $this->htmlEscape($this->getFormData()->getShippingCity()) ?>" title="<?php echo $this->__('Place') ?>" class="input-text required-entry" id="shipping_city" />
                                </div>
                            </div>
                        </li>
                        <li class="field">
                            <div class="field">
                                <label for="shipping_region_id" class="required"><?php echo $this->__('State') ?> <em>*</em></label>
                                <div class="input-box">
                                    <select id="shipping_region_id" name="shipping_region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
                                        <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
                                    </select>
                                    <script type="text/javascript">
                                        //<![CDATA[
                                            $('shipping_region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getShippingRegionId() ?>");
                                        //]]>
                                    </script>
                                    <input type="text" id="shipping_region" name="shipping_region" value="<?php echo $this->htmlEscape($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
                                </div>
                            </div>
                        </li>
                        <li class="fields">
                            <div class="field">
                                <label for="shipping_country" class="required"><?php echo $this->__('Country') ?> <em>*</em></label>
                                <div class="input-box">
                                    <?php echo $this->getCountryHtmlSelect(null, 'shipping_country_id', 'shipping_country_id') ?>
                                </div>
                            </div>
                        </li>
                    </ul>
                    <input type="hidden" name="shipping_default_billing"  value="0" />
                    <input type="hidden" name="shipping_default_shipping" value="1" />
                </div>
            </div>

and change the values of default shipping address hidden field from

 <input type="hidden" name="default_shipping" value="1"/>

To

 <input type="hidden" name="default_shipping" value="0"/>
  • In magento 1, how can i get exact shipping state using observer? @Ranganathan – Gem Aug 23 at 4:33

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.