Tuesday 7 May 2013

Choose customer group on checkout in Magento.

copy config.xml from /app/code/core/Mage/Customer/etc/ to app/code/local/Customer/etc/ and modify like below ( add group_id node ):

<fieldset>
    ...
    <customer_account>
    <email><create>1</create><update>1</update></email>
    <group_id><create>1</create><update>1</update></group_id>
    <!-- add above line -->
    </customer_account>
    ...
</fieldset>

Open register.phtml from /app/design/frontend/[YOUR_TEMPLATE]/customer/form/ and add the following code block somewhere which the field that you want to appear :

<div class="input-box">
   <label for="group_id"><?php echo $this->__('Your customer group') ?>
      <span class="required">*</span> 
   </label>
   <select name="group_id" id="group_id" title="<?php echo $this->__('Customer Groups') ?>" class="validate-group required-entry input-text" />
   <?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
   <?php foreach($groups as $group){ ?>
       <option value="<?php print $group['value'] ?>">
           <?php print $group['label'] ?>
       </option>
   <?php } ?>
   </select>
</div>

No comments:

Post a Comment