Wednesday, January 02, 2013

Add a Javascript alert when the default attributes are selected - Presto-Changeo - Prestashop Modules and Website Development

Add a Javascript alert when the default attributes are selected - Presto-Changeo - Prestashop Modules and Website Development


Default Attribute Alert
This page was written in English, please see the English version for the most accurate code.

Users may not notice there are attributes to select for a product and just click "Add to cart" without realizing they chose the default attributes.

The code changes below create a Javascript alert when the default attributes were not changed, asking the user to confirm their selection.
Change your code to match the one below, the highlighted text needs to be added.
The line numbers may change a bit depending on your version of prestashop, but the actual code is the same.



/module/blockcart/ajax-cart.js (around line 11)

     //for product page 'add' button...
        $('body#product p#add_to_cart input').unbind('click').click(function(){
            if (attribute_alert == true)
            {
                if (!confirm(attribute_alert_text))
                    return false;
            }

            ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
            return false;
        });


/themes/prestashop/product.tpl (line 3)