PluginProbe
YayCurrency – WooCommerce Multi-Currency Switcher / trunk
YayCurrency – WooCommerce Multi-Currency Switcher vtrunk
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 / script.js

script.js in YayCurrency – WooCommerce Multi-Currency Switcher trunk, at src/script.js

51 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 'use strict';
2 (function ($) {
3
4 const yay_currency = () => {
5 if (window.history.replaceState) {
6 window.history.replaceState(null, null, window.location.href);
7 }
8 };
9
10 // Define Filter & Action Hooks from YayCurrency
11 window.yayCurrencyHooks = {
12 addFilter: function (hookName, callback) {
13 YayCurrency_Callback.Helper.addHook('filters', hookName, callback);
14 },
15 applyFilters: YayCurrency_Callback.Helper.applyFilters,
16 addAction: function (hookName, callback) {
17 YayCurrency_Callback.Helper.addHook('actions', hookName, callback);
18 },
19 doAction: YayCurrency_Callback.Helper.doAction
20 };
21
22 jQuery(document).ready(function ($) {
23 yay_currency($);
24 const { yayCurrency } = window;
25 const currencyID = YayCurrency_Callback.Helper.getCookie(yayCurrency.cookie_name);
26
27 // Filter by Price (WooCommerce plugin)
28 YayCurrency_Callback.Helper.handleFilterByPrice(currencyID);
29
30 $(document.body).trigger('wc_fragment_refresh');
31
32 $(window).on('load resize scroll', YayCurrency_Callback.Helper.switcherUpwards());
33
34 // Use Param Url
35 if (yayCurrency.yay_currency_use_params) {
36 if (yayCurrency.yay_currency_param__name && currencyID) {
37 YayCurrency_Callback.Helper.setCookie(yayCurrency.cookie_switcher_name ?? 'yay_currency_do_change_switcher', currencyID, 1);
38 }
39 }
40 // Switcher Action
41 YayCurrency_Callback.Helper.switcherAction();
42
43 // Convert
44 YayCurrency_Callback.Helper.currencyConverter();
45
46 // Compatible with third party [Themes / Plugins]
47 yayCurrencyHooks.doAction('yayCurrencyCompatibleThirdParty', [{ currencyID: currencyID }]);
48
49 });
50 })(jQuery);
51