0

I am trying to remove the telephone and state/province field as a required field in my checkout.

I have already successfully removed it from the shipping section, and I tried to remove it the following way:

1.) I have removed the class="required" and the * from the following files

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

Like I mentioned above the shipping one works fine but the billing not. When template hints are on it does not mention a different template.

2.) I have copied the Abstract.php core class

app/code/core/Mage/Customer/Model/Address/Abstract.php

to

app/code/local/Mage/Customer/Model/Address/Abstract.php

And removed the validation there.

3.) I have set the field in the database to not required.

However in the billing section when I checkout, the telephone field and province field are still required and the "*" is also still coming up.

Am I missing something obvious?

3 Answers 3

0

if the * is still coming up you obviously edited the wrong phtml file, for starters turn on template paths and get the right phtml file to edit

3
  • Did that but it does not show any different .phtml file, it just shows onepage.phtml and no specific billing or shipping.phtml file
    – Klettseb
    Jun 20, 2016 at 14:41
  • screenshot might help Jun 20, 2016 at 14:42
  • screenshot of what exactly?
    – Klettseb
    Jun 20, 2016 at 18:12
0

I had another extension where the billing section was created after editing it, it worked like it should.

I guess template path hints should also be looked at carefully :-)

That was the file

app/design/frontend/base/default/template/outsourceOnline/captcha/onepage_billing.phtml
0

I know is late but in case others are here, for removing region/province, do edit the following:

  • /checkout/onepage/shipping.phtml
  • /checkout/onepage/billing.phtml
  • app/core/Mage/Customer/Model/Adress/Abstract.php
  • /skin/frontend/default/(your skin)/js/opcheckout.js

billing.phtml: Comment out the following

<div class="field">
                        <div class="input-box"  style="display:none" readonly >
                            <select id="billing:region_id" name="billing[region_id]" title="<?php echo Mage::helper('core')->quoteEscape($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[
                                $('billing:region_id').setAttribute('defaultValue',  "<?php echo $this->getAddress()->getRegionId() ?>");
                            //]]>
                            </script>
                            <input type="text" style="display:none" readonly  id="billing:region" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"  title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" placeholder="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                        </div>
                    </div>

shipping.phtml: Comment out the following (same codes as billing.phtml)

<div class="field">
                        <label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
                        <div class="input-box">
                            <select id="shipping:region_id" name="shipping[region_id]" title="<?php echo Mage::helper('core')->quoteEscape($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->getAddress()->getRegionId() ?>");
                            //]]>
                            </script>
                            <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                        </div>
                    </div>

Abstract.php: Comment out the following

        if ($this->getCountryModel()->getRegionCollection()->getSize()
        && !Zend_Validate::is($this->getRegionId(), 'NotEmpty')
        && Mage::helper('directory')->isRegionRequired($this->getCountryId())
    ) {
        $this->addError(Mage::helper('customer')->__('Please enter the state/province.'));
    }

opcheckout.js: Comment out the following.

1st part

if (window.billingRegionUpdater) {
                billingRegionUpdater.update();
            }

2nd part

if (window.shippingRegionUpdater) {
                shippingRegionUpdater.update();
            }

3rd part

 shippingRegionUpdater.update();
        $('shipping:region_id').value = $('billing:region_id').value;
        $('shipping:region').value = $('billing:region').value;

4th part

setRegionValue: function(){
    $('shipping:region').value = $('billing:region').value;
},

You should be fine by now.

Your Answer

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

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