PluginProbe
YayCurrency – WooCommerce Multi-Currency Switcher / 2.3
YayCurrency – WooCommerce Multi-Currency Switcher v2.3
3.3.5 trunk 2.0.1 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.1 2.2 2.3 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 3.0.0 3.0.1 3.0.2 3.1 3.2 3.3 3.3.1 All 28 releases
yaycurrency / src / analytics.js

analytics.js in YayCurrency – WooCommerce Multi-Currency Switcher 2.3, at src/analytics.js

43 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 'use strict';
2 const ready = function ready(fn) {
3 return (
4 document.attachEvent
5 ? document.readyState === 'complete'
6 : document.readyState !== 'loading'
7 )
8 ? fn()
9 : document.addEventListener('DOMContentLoaded', fn);
10 };
11 ready(function () {
12 const { addFilter } = wp.hooks;
13 const { __ } = wp.i18n;
14
15 const addCurrencyFilters = (filters) => {
16 return [
17 {
18 label: __('Currency', 'yay-currency'),
19 staticParams: [],
20 param: 'currency',
21 showFilters: () => true,
22 defaultValue: yayCurrencyAnalytics.defaultCurrency,
23 filters: [...(wcSettings.multiCurrency || [])],
24 },
25 ...filters,
26 ];
27 };
28
29 const currencies = Object.assign({}, ...yayCurrencyAnalytics.currencies);
30 const updateReportCurrencies = (config, { currency }) => {
31 if (currency && currencies[currency]) {
32 return currencies[currency];
33 }
34 return config;
35 };
36
37 addFilter(
38 'woocommerce_admin_report_currency',
39 'yay-currency',
40 updateReportCurrencies
41 );
42 });
43