Magento – Remove required validation from address checkout – Magento 1.9

customer-addressmagento-1.9onepage-checkoutvalidation

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

Best Answer

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.

Related Topic