// source --> https://www.labeerepoque.be/wp-content/plugins/kliken-marketing-for-google/assets/kk-script.js?ver=6.8.10 
function klikenGetCartItems() {
    jQuery.post(fetchCartItems.ajax_url, {
        action: fetchCartItems.action,
        _ajax_nonce: fetchCartItems.nonce
    }, function (data) {
        // If no data is available, exit method.
        if (typeof sw !== 'object' || !data) return;

        let itemsForFBQ = [];
        let itemsForGTAG = [];
        let swCart = [];

        sw.config.currency = fetchCartItems.currency;

        for (let item in data) {
            itemsForFBQ.push({
                "id": `${data[item].product_id}`,
                "quantity": `${data[item].quantity}`
            });

            itemsForGTAG.push({
                "id": `${data[item].product_id}`,
                "name": `${data[item].product_name}`,
                "price": `${data[item].price}`,
                "quantity": `${data[item].quantity}`,
                "google_business_vertical": "retail"
            });

            swCart.push({
                "id": `${data[item].product_id}`,
                "name": `${data[item].product_name}`,
                "price": `${data[item].price}`,
                "quantity": `${data[item].quantity}`,
                "currency": sw.config.currency
            });
        }

        sw.track("AddToCart",
        {
            "content_type": "product",
            "contents": itemsForFBQ
        });

        sw.gEvent("add_to_cart",
        {
            "items": itemsForGTAG
        });

        sw.register_shopcart(
        {
            "items": swCart
        });
    });
}

jQuery(document).ready(function () {
    // Listen to those events.
    // 1. added_to_cart: A product is added to cart via AJAX.
    // 2. updated_cart_totals: Cart info changed, such as product quantity changed, or items being removed (not emptied).
    jQuery('body').on('added_to_cart updated_cart_totals', function () {
        klikenGetCartItems();
    });
});
// source --> https://www.labeerepoque.be/wp-content/themes/oceanwp-child/js/lbe-custom.js?ver=6.8.10 
/*jQuery(document).ready(function () {
    jQuery(window).on("resize", function (e) {
        checkScreenSize();
    });
    checkScreenSize();
    function checkScreenSize(){
        var newWindowWidth = jQuery(window).width();
        if (newWindowWidth < 768) {
            var delay = 10; setTimeout(function() { 
                jQuery('.elementor-tab-title').removeClass('elementor-active');
                jQuery('.elementor-tab-content').css('display', 'none'); }, delay);
        }
        else{
                 jQuery('.elementor-tab-title[aria-selected="true"]').addClass('elementor-active');
                jQuery('.elementor-tab-content[aria-selected="true"]').css('display', 'block');
        }
    }
});*/
jQuery(document).ready(function () {
    jQuery(window).on("resize", function (e) {
        checkScreenSize();
    });
    checkScreenSize();
    function checkScreenSize(){
        var newWindowWidth = jQuery(window).width();
        if (newWindowWidth < 768) {
            jQuery('.elementor-tab-title span.tab-less').remove();
            jQuery('.elementor-tab-title span.tab-plus').remove();
            jQuery('.elementor-tab-title[aria-selected="true"]').append('<span class="tab-less">-</span>');
            jQuery('.elementor-tab-title[aria-selected="false"]').append('<span class="tab-plus">+</span>');
            
        }
        else{
            jQuery('.elementor-tab-title span.tab-less').remove();  
            jQuery('.elementor-tab-title span.tab-plus').remove();  
        }
    }
    /* COUPON POSITION */
    var couponLink = jQuery(".woocommerce-form-coupon-toggle");
    var coupon = jQuery(".checkout_coupon");
    coupon.insertAfter('.woocommerce-checkout-review-order-table');
    couponLink.insertAfter('.woocommerce-checkout-review-order-table');
});