cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 pop-up modal/alert on add to cart

Magento 1.9 pop-up modal/alert on add to cart

Hi guys, I am working to create a theme based on the rwd theme, and I would like a modal pop-up or a simple alert box when the add to cart is clicked. I know how id' achieve this in normal websites with bootstrap etc. But, lost as how to achieve this in magento.

 

If anyone could even guide me to the location of the code responsible for the add to cart function: where the product gets added and redirected to the shopping cart page; i'd be extremely grateful. 

 

Update

 

 

<script type="text/javascript">
        //<![CDATA[
            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);

            productAddToCartForm.submitLight = function(button, url){
                if(this.validator) {
                    var nv = Validation.methods;
                    delete Validation.methods['required-entry'];
                    delete Validation.methods['validate-one-required'];
                    delete Validation.methods['validate-one-required-by-name'];
                    // Remove custom datetime validators
                    for (var methodName in Validation.methods) {
                        if (methodName.match(/^validate-datetime-.*/i)) {
                            delete Validation.methods[methodName];
                        }
                    }

                    if (this.validator.validate()) {
                        if (url) {
                            this.form.action = url;
                        }
                        
                        this.form.submit();
                    }
                    Object.extend(Validation.methods, nv);
                }
            }.bind(productAddToCartForm);
        //]]>
        </script>

This is the code I believe handling the 'Add to cart' function. Now, I need to figure out how if 'valid' then alert.

2 REPLIES 2

Re: Magento 1.9 pop-up modal/alert on add to cart

lots of free extension available for this

https://www.magentocommerce.com/magento-connect/ajax-cart-popup.html

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

Re: Magento 1.9 pop-up modal/alert on add to cart

Came across that extension before: Would I be able to customise the modal pop-up?

 

I just need the pop-up to be as such:

 

Would you also like to order product B?

 

[No] [Yes]

 

-IF no go to checkout

-IF YES go to product B  product page.