Question

This is my product page

If customer no select storage or color and click "add to cart" nothing happens so I want make popup with hints but I dont know wherein the file and how it should look condition.

Was it helpful?

Solution

Your ajax add to cart JS overriding default productAddToCartForm.submit function.

You can find this unction end of the JS file

jQuery(document).ready(function($) {
    SnsProaddto.init();
    setInterval("SnsProaddto.init()", 1000);
    window.setLocation = function(args) {
        if (args.indexOf('checkout/cart/add') !== -1) {
            SnsProaddto.locationAddtocart(args);
        } else if (args.indexOf('?options=cart')) {
            SnsProaddto.destroyImgFly();
            window.location = args;
            //SnsProaddto.displayOptions();
        }
    }
    if (typeof productAddToCartForm != 'undefined') {
        productAddToCartForm.submit = function() {
            if (this.validator.validate()) {
                SnsProaddto.destroyImgFly();
                jQuery('#proaddto_loading').show();
                var dataf = jQuery('#product_addtocart_form').serialize();
                dataf += '&isAjax=1';
                url = jQuery('#product_addtocart_form').attr('action');
                url = url.replace("checkout/cart", "proaddto/index");
                url = SnsProaddto.cleanUrl(url);
                jQuery.ajax({
                    url: url,
                    dataType: 'json',
                    type: 'post',
                    data: dataf,
                    success: function(data) {
                        jQuery('#proaddto_loading').hide();
                        SnsProaddto.setCartResult(data);
                        SnsProaddto.flyImgToCart();
                    }
                });
            }

            else {
                // popup condition
            }
        }
    }
});

OTHER TIPS

code

 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;
                }
            }
            else {
                alert("dddddd");
            }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top