PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.4
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.4
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / compatibility / plugin / class-wpfnl-fax-currency.php

class-wpfnl-fax-currency.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.4, at includes/core/compatibility/plugin/class-wpfnl-fax-currency.php

62 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPFunnels\Compatibility\Plugin;
4
5 use WPFunnels\Traits\SingletonTrait;
6
7 class FoxCurrencySwitcher extends PluginCompatibility{
8 use SingletonTrait;
9
10 /**
11 * Constructor: Initialize class and hook into price conversion.
12 */
13 public function init(){
14 add_filter('wpfunnels/modify_order_bump_price_on_main_order', array($this,'maybe_convert_product_price'));
15 add_filter('wpfunnels/modify_order_bump_product_price', array($this, 'maybe_convert_order_bump_price'));
16 }
17
18 /**
19 * Check if the Currency (WOOCS) is active.
20 *
21 * @return bool
22 */
23 public function maybe_activate(){
24 return class_exists('WOOCS');
25 }
26
27 /**
28 * Convert the price for the order bump using the current currency
29 *
30 * @param float $price
31 * @return float Converted price
32 */
33 public function maybe_convert_product_price($price){
34 global $WOOCS;
35
36 if ($this->maybe_activate()) {
37 if ($WOOCS->is_multiple_allowed) {
38 $current = $WOOCS->current_currency;
39 if ($current != $WOOCS->default_currency) {
40 $currencies = $WOOCS->get_currencies();
41 $rate = $currencies[$current]['rate'];
42 $price = $price / $rate;
43 }
44 }
45 }
46
47 return $price;
48 }
49
50 public function maybe_convert_order_bump_price($price){
51 global $WOOCS;
52
53 if ($this->maybe_activate()) {
54 if ($WOOCS->is_multiple_allowed) {
55 $price = $WOOCS->woocs_exchange_value(floatval($price));
56 }
57 }
58
59 return $price;
60 }
61 }
62