cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove validation on product detail page

how to remove validation on product detail page

hai..

 

i want one option.

 

when am click on add to cart  button at product detail page does not show "please specify the options" validation.

 

i dont want to validate the conditions on that page.

 

can you help us.

 

Thanks,

Premalatha.S

 

4 REPLIES

Re: how to remove validation on product detail page

In your site theme try to search for a snippet like this:

(in the basic theme it's located here app/design/frontend/base/default/template/catalog/product/view.phtml)

 

var productAddToCartForm = new VarienForm('product_addtocart_form');
        productAddToCartForm.submit = function(button, url) {
            if (this.validator.validate()) {
                var form = this.form;
                var oldUrl = form.action;

                if (url) {
                   form.action = url;
                }
                var e = null;
                try {
                    this.form.submit();
                } catch (e) {
                }
                this.form.action = oldUrl;
                if (e) {
                    throw e;
                }

                if (button && button != 'undefined') {
                    button.disabled = true;
                }
            }
        }.bind(productAddToCartForm);

 and delete the condition responsible for validation:

if (this.validator.validate()

BUT, note that this is quite a compromise. The point is that any item that has empty required options won't get added to the shopping cart.

So, you'd better use the non-required options or set the option's default values.

______________________________________________________________
Innovative, top-performing Magento Extensions (with an array of FREE tools).

Re: how to remove validation on product detail page

hai..

 

Thank you.

 

I removed that function but again repeat the validation required option.

 

I will try another way, In backend i set values required for relevant attributes as no.  This also failed.

 

can you help me..

Re: how to remove validation on product detail page

@prema92


Please try to find product display in your theme template (in the default theme this is the file app/design/frontend/base/default/template/catalog/product/view.phtml)

It should look smth like that:

var productAddToCartForm = new VarienForm('product_addtocart_form');
        productAddToCartForm.submit = function(button, url) {
            if (this.validator.validate()) {
                var form = this.form;
                var oldUrl = form.action;

                if (url) {
                   form.action = url;
                }
                var e = null;
                try {
                    this.form.submit();
                } catch (e) {
                }
                this.form.action = oldUrl;
                if (e) {
                    throw e;
                }

                if (button && button != 'undefined') {
                    button.disabled = true;
                }
            }
        }.bind(productAddToCartForm);

and DELETE the condition that is in charge of implementing validation:

 

if (this.validator.validate())


But anyway, that is not an ideal solution, as all products that don't have data in the required fields won't get added to the shopping cart.

So you should use the options that are not required, or set the value of your options by default.

Hope it helps.

______________________________________________________________
Innovative, top-performing Magento Extensions (with an array of FREE tools).

Re: how to remove validation on product detail page

@prema92Oops, sorry, just noticed your second post. 

 

Well, if you have removed the validation script, refreshed the cache but that didn't help to remove validation, most likely, you forgot to remove it in the template itself. Make sure that after you implement all changes, all that will be reflected in the template as well.

 

 

 

 

 

 

______________________________________________________________
Innovative, top-performing Magento Extensions (with an array of FREE tools).