how to override JavaScript function

REAL FUNCTION

compare = {
        add: function(t) {
            $.ajax({
                url: "index.php?route=product/compare/add",
                type: "post",
                data: "product_id=" + t,
                dataType: "json",
                success: function(t) {
                    $(".alert").remove(), t.success && ($.colorbox({
                        html: '<div class="cart_notification"><div class="product"><img src="' + t.image + '"/><span>' + t.success + '</span></div><div class="bottom"><a class="btn btn-primary" href="' + t.link_compare + '">' + t.text_compare + "</a></div></div>",
                        className: "login",
                        initialHeight: 50,
                        initialWidth: 50,
                        width: "90%",
                        maxWidth: 400,
                        height: "90%",
                        maxHeight: 200
                    }), $("#compare-total").html(t.total), $("#header_compare").html(t.compare_total))
                }
            })
        },
        remove: function() {}
    };
---------------------------------------------------------------
----------------------------------------------------------------

OVERIDE  FUNCTION


compare.add = function(t) {
$.ajax({
                url: "index.php?route=product/compare/add",
                type: "post",
                data: "product_id=" + t,
                dataType: "json",
                success: function(t) {
                    $(".alert").remove(), t.success && ($.colorbox({
                        html: '<div class="cart_notification"><div class="product"><img src="' + t.image + '"/><span>' + t.success + '</span></div><div class="bottom"><a class="btn btn-primary" href="' + t.link_compare + '">' + t.text_compare + "</a> <a class='btn btn-primary' onclick='removebox();'>Add another product</a></div></div>",
                        className: "login",
                        initialHeight: 50,
                        initialWidth: 50,
                        width: "90%",
                        maxWidth: 400,
                        height: "90%",
                        maxHeight: 200
                    }), $("#compare-total").html(t.total), $("#header_compare").html(t.compare_total))
                }
            })
}

FOR more information how to override follow this link:-

Popular posts from this blog

How to open cPanel using WHM access.

Cant use dump() function in twig files or how to enable debug in opencart twig or print_r alternate use dump() in opencart 3.0