1

I have a magento website that is going to be used solely for free digital downloads. I want people to register to keep track of who is taking the software but I only really want them to give their name, email, basic geo location, and their phone number. Their address ,zip ect. I do not need. Is there an easy way I can remove the required field jquery call from the onepage checkout?

enter image description here

Thanks

1
  • goto billing.phtml and remove required class for that textbox then chek it
    – Magento 2
    Mar 3, 2016 at 19:13

4 Answers 4

2

Override method in class:Mage_Customer_Helper_Address::getAttributeValidationClass($attributeCode) to something like:

    public function getAttributeValidationClass($attributeCode)
{
    /** @var $attribute Mage_Customer_Model_Attribute */
    $attribute = isset($this->_attributes[$attributeCode]) ? $this->_attributes[$attributeCode]
        : Mage::getSingleton('eav/config')->getAttribute('customer_address', $attributeCode);

    if (in_array($attributeCode, array('firstname', 'lastname', 'country'))){
    $class = $attribute ? $attribute->getFrontend()->getClass() : '';
   }

    if (in_array($attributeCode, array('firstname', 'middlename', 'lastname', 'prefix', 'suffix', 'taxvat'))) {
        if ($class && !$attribute->getIsVisible()) {
            $class = ''; // address attribute is not visible thus its validation rules are not applied
        }

        /** @var $customerAttribute Mage_Customer_Model_Attribute */
        $customerAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
        $class .= $customerAttribute && $customerAttribute->getIsVisible()
            ? $customerAttribute->getFrontend()->getClass() : '';
        $class = implode(' ', array_unique(array_filter(explode(' ', $class))));
    }

    return $class;
}

After that extend app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml app/design/frontend/rwd/default/template/persistent/checkout/onepage/shipping.phtml

templates in your own custom theme and remove the required * and for fields like postcode remove the call to $this->helper('customer/address')->getAttributeValidationClass('postcode') in the html for these fields.

1

In your local.xml file of your theme, add the following layout handle, clear your cache and all address form fields will vanish.

<customer_account_create>
<reference name="customer_form_register">
    <action method="setData"><key>show_address_fields</key><value>0</value></action>
</reference>
</customer_account_create>
0

A simple edit of the template to remove the required won't work as you have PHP validation as well. To do this properly you would need to edit code as well.

However without overriding any code, I would say the easiest is to copy the template, hide all the fields you are not going to use and for the required ones give them a value of - (or n/a etc) inside the template. It will have value, it will validate. And where you need to show the values for the customer, don't use the "fake filled" fields.

0

1- Remove the required class from following files in your theme folder.

checkout/onepage/shipping.phtml
checkout/onepage/billing.phtml
persistent/checkout/onepage/billing.phtml

<!--<label for="shipping:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>-->
<label for="shipping:telephone"><?php echo $this->__('Telephone') ?></label>

also remove classes from input field as-well

<?php //echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>

2- copy this core class to your local and remove following lines app/code/core/Mage/Customer/Model/Address/Abstract.php

/*if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
  $this->addError(Mage::helper('customer')->__('Please enter the telephone number.'));
}*/

3- Change the attribute is_required in DB

update eav_attribute set is_required=0 where attribute_code='telephone';

Note: step three is a dirty hack, correct way would be creating an setup file in your custom extension.

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.