<?php
defined("ABSPATH") || exit();
//INCLUDED IN CLASS JS

$js .= "
jQuery(function ($) {
    $('.uicore-cart-icon.uicore-link').click(function () {
        //continue only if the parent of this element is not a link
        if ($(this).parent().is('a')) {
            return;
        }
        $('body').addClass('uicore-cart-active');
    });
    $('#cart-wrapper').click(function () {
        $('body').removeClass('uicore-cart-active');
    });

    $('#uicore-cart-close').click(function () {
        $('body').removeClass('uicore-cart-active');
    });
    $('body').on('added_to_cart',function(e, fragments){
        if($('#uicore-site-header-cart').length) {
            $('body').addClass('uicore-cart-active');
        } else {
            const content = '<a href=\"' + wc_add_to_cart_params.cart_url + '\">' + wc_add_to_cart_params.i18n_view_cart + '</a>';
            $('body').append('<div class=\"uicore-added_to_cart\">' + content + '</div>');
            setTimeout(function () {
                $('.uicore-added_to_cart').fadeOut(500, function () { $(this).remove(); });
            }, 7000);
        }
    });
});
";

