woocs_form_method
Allows to change WOOCS form method from POST to GET
1 2 3 | add_action( 'woocs_form_method', function(){ return 'get'; }); |
From 2.2.0/1.20
Allows to change WOOCS form method from POST to GET
1 2 3 | add_action( 'woocs_form_method', function(){ return 'get'; }); |
From 2.2.0/1.20
Works in index.php -> public function woocommerce_variation_prices -> can be used for any manipulations with variable prices, for example rounding of them. Add next code in functions.php of your current wp theme: Example:
1 2 3 | add_filter('woocs_woocommerce_variation_prices', function($price) { return round($price * 2, 0) / 2; }); |
The hook is applied in file wp-content\plugins\woocommerce-currency-switcher\views\shortcodes\woocs.php for the text manipulation in the switchers drop-down. Example:
1 2 3 4 | add_filter('woocs_currname_in_option', function($currency_name){ //return "Hello " . $currency_name . '!!'; return ""; }); |
Use it by your own logic. Customer request: How can i make sure that there is only a currency symbol in the dropdown without editing the plugin files, so updates are possible. DDSlick dropdown preferred
This hook allows to manipulate by currency on the checkout page if in tab Advanced enabled “Checkout by GeoIP rules” option. If “Checkout by GeoIP rules” is enabled and country not described in GEO-IP rules checkout will be done with currency selected by user. Using this hook its possible to change this situation:
1 2 3 4 5 6 7 | add_action('woocs_force_pay_bygeoip_rules', function($country, $user_currency, $current_currency) { global $WOOCS; if (!empty($user_currency)) { $WOOCS->set_currency($user_currency); } }, 9999, 3); |
Or […]
Use this hook to manipulate by price values, for example rounding price by your own logic. Examples: https://currency-switcher.com/how-to-round-price-to-50-cents/ – rounding price to the nearest 50 cents
1 2 3 | add_filter('woocs_raw_woocommerce_price', function($price) { return round($price * 2, 0) / 2; }); |
https://currency-switcher.com/round-prices-500/ – How to round prices to 500
1 2 3 4 5 6 7 8 9 10 11 | add_filter('woocs_raw_woocommerce_price', function($price) { if (($price <= 1000)) { $price = round($price / 1000, 0) * 1000; return $price; } else { $price = ceil($price / 500) * 500; return $price; } }); |
https://currency-switcher.com/how-to-round-price-to-99-cents/ – How to round prices to x.99 Also read: https://currency-switcher.com/hook/woocs_woocommerce_variation_prices/
Use this hook when you activated ‘Show approx. amount’ option in the plugin settings and you want to change default text on the cart/checkout page generated by this feature ‘(Approx. %s)’ to smth another. Example:
1 2 3 4 5 | add_filter('woocs_get_approximate_amount_text', 'my_woocs_get_approximate_amount_text', 999, 2); function my_woocs_get_approximate_amount_text($text, $wc_price) { return sprintf(__('(My Approx. %s)'), $wc_price); } |
$text (string) $wc_price (string) ‘Show approx. amount’ – Show approximate amount on the checkout and the cart page with currency of […]
Use this hook if you want to add any additional information text after a product price on the shop/category page. Example:
1 2 3 4 | add_filter('woocs_price_html_tail', function($price_html) { return $price_html . "<strong>Hello World!</strong>"; }); |
Combine it with CSS (in style.css) code if necessary:
1 2 3 4 5 6 7 8 9 10 11 | .woocs_price_html_tail{ display: none; } body.single-product .woocs_price_html_tail{ display: block; } body.single-product .related .woocs_price_html_tail{ display: none; } |
This hook uses in index.php of the plugin -> public function woocommerce_price_format:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | public function woocommerce_price_format() { $currencies = $this->get_currencies(); $currency_pos = 'left'; if (isset($currencies[$this->current_currency])) { $currency_pos = $currencies[$this->current_currency]['position']; } $format = '%1$s%2$s'; switch ($currency_pos) { case 'left' : $format = '%1$s%2$s'; break; case 'right' : $format = '%2$s%1$s'; break; case 'left_space' : $format = '%1$s %2$s'; break; case 'right_space' : $format = '%2$s %1$s'; break; } return apply_filters('woocs_price_format', $format, $currency_pos); } |
So if you have any idea about your own price format use this hook with/without any conditions by your own logic:
1 2 3 4 5 6 7 | add_filter('woocs_price_format', 'my_woocs_custom_format', 999, 2); function my_woocs_custom_format($format, $currency_pos) { //do smth with $format here return $format; } |
This hook uses in public function get_currencies of the plugin:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | public function get_currencies() { $default = array( 'USD' => array( 'name' => 'USD', 'rate' => 1, 'symbol' => '$', 'position' => 'right', 'is_etalon' => 1, 'description' => 'USA dollar', 'hide_cents' => 0, 'flag' => '', ), 'EUR' => array( 'name' => 'EUR', 'rate' => 0.89, 'symbol' => '€', 'position' => 'left_space', 'is_etalon' => 0, 'description' => 'Europian Euro', 'hide_cents' => 0, 'flag' => '', ) ); $currencies = get_option('woocs', $default); $currencies = apply_filters('woocs_currency_data_manipulation', $currencies); if (empty($currencies) OR ! is_array($currencies)) { $currencies = $default; } return $currencies; } |
So you can use it for any manipulations with the currencies data. Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | add_filter('woocs_currency_data_manipulation', 'my_woocs_currency_data_manipulation', 1, 1); function my_woocs_currency_data_manipulation($currencies) { foreach ($currencies as $key => $value) { if ($key == 'USD') { $currencies[$key]['rate'] = $value['rate'] + 0.10; break; } } return $currencies; } |
p.s. From v.2.2.9/1.2.9 interest to currencies rate it is possible to add directly in the currencies options tab!!
This hook created for manipulations with the currency switcher drop-down skins when its necessary, with any logic conditions, for example set usual drop-down skin in for mobile site view:
1 2 3 4 5 6 7 8 9 10 11 | add_filter('woocs_drop_down_view', 'woocs_drop_down_view', 999); function woocs_drop_down_view($view) { if (wp_is_mobile()) { return 'no'; } return $view; } |
Its possible to use next values: no, ddslick, chosen, chosen_dark, wselect, flags Disable switcher drop-down skin in the AJAX mode of your site:
1 2 3 4 5 6 7 8 9 10 11 | add_filter('woocs_drop_down_view', 'woocs_drop_down_view', 999); function woocs_drop_down_view($view) { if (defined('DOING_AJAX') && DOING_AJAX) { return 'no'; } return $view; } |
https://codex.wordpress.org/Function_Reference/wp_is_mobile Set any another skin for the currency switcher drop-down on the […]