HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //proc/self/cwd/wp-content/plugins/woo-multi-currency/js/woo-multi-currency.js
jQuery(document).ready(function ($) {
    'use strict';
    window.woo_multi_currency = {

        init: function () {
            this.design();
            this.checkPosition();
            this.cacheCompatible();
            this.ajaxComplete();
        },

        design: function () {
            var windowsize = jQuery(window).width();
            if (windowsize <= 768) {
                jQuery('.woo-multi-currency.wmc-sidebar').on('click', function () {
                    jQuery(this).toggleClass('wmc-hover');
                    if (jQuery(this).hasClass('wmc-hover')) {
                        jQuery('html').css({'overflow': 'hidden'});
                    } else {
                        jQuery('html').css({'overflow': 'visible'});
                    }
                })
            } else {
                /*replace hover with mouseenter mouseleave in some cases to work correctly*/
                jQuery('.woo-multi-currency.wmc-sidebar').on('mouseenter', function () {
                    let $this = jQuery(this);
                    $this.addClass('wmc-hover');
                });
                jQuery('.woo-multi-currency.wmc-sidebar').on('mouseleave', function () {
                    let $this = jQuery(this);
                    $this.removeClass('wmc-hover');
                })
            }
        },

        checkPosition: function () {
            jQuery('.woo-multi-currency .wmc-currency-wrapper').on('mouseenter', function () {
                if (this.getBoundingClientRect().top / $(window).height() > 0.5) {
                    $('.woo-multi-currency .wmc-sub-currency').addClass('wmc-show-up');
                } else {
                    $('.woo-multi-currency .wmc-sub-currency').removeClass('wmc-show-up');
                }
            });
        },

        cacheCompatible() {
            if (wooMultiCurrencyParams.enableCacheCompatible === '1') {

                if (typeof wc_checkout_params !== 'undefined') {
                    if (parseInt(wc_checkout_params.is_checkout) === 1) return;
                }

                let pids = [];
                let simpleCache = $('.wmc-cache-pid');
                if (simpleCache.length) {
                    simpleCache.each(function (i, element) {
                        pids.push($(element).data('wmc_product_id'));
                    });
                }

                let variationCache = $('.variations_form');
                if (variationCache.length) {
                    variationCache.each(function (index, variation) {
                        let data = $(variation).data('product_variations');
                        if (data.length) {
                            data.forEach((element) => {
                                pids.push(element.variation_id);
                            });
                        }
                    });
                }

                let currentShortcode = $('.woo-multi-currency.wmc-shortcode');
                if (pids.length) pids = [...new Set(pids)]; //remove duplicate element

                let exchangePrice = [];
                $('.wmc-cache-value').each(function (i, element) {
                    exchangePrice.push({value: $(element).data('value'), currency: $(element).data('currency')});
                });
                exchangePrice = [...new Set(exchangePrice.map(JSON.stringify))].map(JSON.parse);

                $.ajax({
                    url: wooMultiCurrencyParams.ajaxUrl,
                    type: 'POST',
                    data: {
                        action: 'wmc_get_products_price',
                        pids: pids,
                        shortcode: currentShortcode.data('layout'),
                        flag_size: currentShortcode.data('flag_size'),
                        wmc_current_url: currentShortcode.find('.wmc-current-url').val(),
                        exchange: exchangePrice
                    },
                    success(res) {
                        if (res.success) {
                            let prices = res.data.prices || '',
                                currentCurrency = res.data.current_currency || '',
                                exSc = res.data.exchange || '';

                            currentShortcode.replaceWith(res.data.shortcode);

                            if (wooMultiCurrencyParams.switchByJS !== '1') {
                                $('.wmc-currency a').unbind();
                            }

                            if (currentCurrency) {
                                /*Sidebar*/
                                $('.wmc-sidebar .wmc-currency').removeClass('wmc-active');
                                $(`.wmc-sidebar .wmc-currency[data-currency=${currentCurrency}]`).addClass('wmc-active');
                                /***Currency switcher in product page***/
                                $('.wmc-price-switcher .wmc-current-currency i').removeClass().addClass('vi-flag-64 flag-' + res.data.current_country);
                                $(`.wmc-price-switcher .wmc-currency[data-currency=${currentCurrency}]`).hide();

                                $(`select.wmc-nav option[data-currency=${currentCurrency}]`).prop('selected', true);
                            }
                            // woo_multi_currency.disableCurrentCurrencyLink();
                            if (typeof woo_multi_currency_switcher !== 'undefined') {
                                woo_multi_currency_switcher.init();
                            }


                            if (prices) {
                                for (let id in prices) {
                                    $(`.wmc-cache-pid[data-wmc_product_id=${id}]`).replaceWith(prices[id]);
                                }

                                $('.variations_form').each((i, form) => {
                                    let data = $(form).data('product_variations');
                                    data.map((element) => {
                                        let pid = element.variation_id;
                                        element.price_html = prices[pid];
                                        return element
                                    });
                                    $(form).data('product_variations', data);
                                });
                            }

                            if (exSc) {
                                for (let i in exSc) {
                                    if (exSc[i]['currency']) {
                                        $(`.wmc-cache-value[data-value=${exSc[i]['value']}][data-currency=${exSc[i]['currency']}]`).replaceWith(exSc[i]['shortcode']);
                                    } else {
                                        $(`.wmc-cache-value[data-value=${exSc[i]['value']}][data-currency='']`).replaceWith(exSc[i]['shortcode']);
                                    }
                                }
                            }
                        }
                    }
                });
            }
        },

        ajaxComplete() {
            $(document).on('append.infiniteScroll', () => {
                this.cacheCompatible();
            });
        }
    };

    woo_multi_currency.init();
});