Fly to cart addon for Opencart e-commerce

Made this jquery function for a friends so you don't to hack the core files. You need to just put this anywhere in the footer, or better in custom.js of your template.

jQuery(document).ready(function ($) {
    $("input[value='Add to Cart']").each(function () {
        product_id = $(this).attr('onclick').match(/(\d+)/)[0]

        $(this).attr('onclick', '').unbind('click').click(function (event) {
            //event.preventDefault();

            adt = $(this)
            quantity = typeof (quantity) != 'undefined' ? quantity : 1;

            $.ajax({
                url: 'index.php?route=checkout/cart/add',
                type: 'post',
                data: 'product_id=' + product_id + '&quantity=' + quantity,
                dataType: 'json',
                success: function (json) {
                    $('.success, .warning, .attention, .information, .error').remove();

                    if (json['redirect']) {
                        location = json['redirect'];
                    }

                    if (json['success']) {
                        // fly me to the moon

                        var cart = $('#cart');

                        var imgtodrag = $(adt).parent().siblings('div.image').find("img").eq(0);


                        if (imgtodrag) {
                            var imgclone = imgtodrag.clone()
                                .offset({
                                    top: imgtodrag.offset().top,
                                    left: imgtodrag.offset().left
                                })
                                .css({
                                    'opacity': '0.5',
                                    'border': '1px dashed #666',
                                    'position': 'absolute',
                                    'height': '150px',
                                    'width': '150px',
                                    'z-index': '100'
                                })
                                .appendTo($('body'))
                                .animate({
                                    'top': cart.offset().top + 10,
                                    'left': cart.offset().left + 10,
                                    'width': 75,
                                    'height': 75
                                }, 1000, 'easeInOutExpo');

                            setTimeout(function () {
                                cart.effect("shake", {
                                    times: 2
                                }, 200);
                            }, 1500);

                            imgclone.animate({
                                'width': 0,
                                'height': 0
                            }, function () {
                                $(this).detach()
                            });
                        }


                        // end - fly me to the moon


                        $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<i id="closeicon" onclick="$(this).parent().fadeOut(\'fast\');" class="icon-remove padleft handpoint flright"></i></div>');
                        $('.success').fadeIn('slow');
                        $('#cart-total').html(json['total']);


                    }
                }
            });
        })
    })
})

You may need to make sure you get the right div for image. I'd say it works better if you have a sticky header with cart element inside. Enjoy!