2

I simply would like to make the field "company" on the onepage checkout a required field. Would be happy for some help? I tried it already but it didn't work, so probably I have to change or add some more data in another file.

1
  • Hi Cris, welcome to Magento SE. Please edit your question and add what you have tried so far. Include your question with code samples or queries that you have used to try to get this to work.
    – 7ochem
    Jan 14, 2016 at 15:53

2 Answers 2

2

In magento by default customer address attribute "company" is not required.If you need required then update company attribute to bellow php script.

Run bellow script to update attribute

$installer = new Mage_Customer_Model_Entity_Setup('core_setup');
$installer->startSetup();


/*** Update customer address attributes*/
$installer->updateAttribute('customer_address', 'company', 'is_required', 1); 

$installer->endSetup();
2

Ok so the following code is only valid for the base/default template you may have to adapt it if you're using a custom theme.

Replace the following code under app/design/frontend/base/default/template/checkout/onepage/billing.phtml:

<div class="field">
    <label for="billing:company"><?php echo $this->__('Company') ?></label>
    <div class="input-box">
        <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
    </div>
</div>

With the following:

<div class="field">
    <label for="billing:company" class="required"><em>*</em><?php echo $this->__('Company') ?></label>
    <div class="input-box">
        <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text required-entry <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
    </div>
</div>

Repeat the process with the app/design/frontend/base/default/template/checkout/onepage/shipping.phtml template:

<div class="fields">
    <label for="shipping:company"><?php echo $this->__('Company') ?></label>
    <div class="input-box">
        <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" onchange="shipping.setSameAsBilling(false);" />
    </div>
</div>

With:

<div class="fields">
    <label for="shipping:company" class="required"><em>*</em><?php echo $this->__('Company') ?></label>
    <div class="input-box">
        <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text required-entry <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" onchange="shipping.setSameAsBilling(false);" />
    </div>
</div>

Your Answer

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

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