0

I am new in Magento field. can you buddy help me to make understand how "add to cart button" validation HTML filed can find and works .? I reached

/var/www/html/magento/app/design/frontend/rwd/default/template/catalog/product/view/addtocart.phtml.

/var/www/html/magento/app/design/frontend/rwd/default/layout/catalog.xml

/var/www/html/magento/app/design/frontend/rwd/default/template/catalog/product/view.phtml

/catalog/product/view.phtml in this folder what should I analyze to understand about "add to cart" button validation please tell me to step by step with folder and directory name.

0

Find Add to Cart Button HTML

<button type="button" title="Add to Cart" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span>Add to Cart</span></span></button>

onclick it will call

var productAddToCartForm = new VarienForm('product_addtocart_form'); // prototype VarienForm object.

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);

As you go through each input field of product_addtocart_form you will get validation class added into field.

get list of validation class on inchoo.

to find location of each HTML fields refer this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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