PluginProbe
Packeta / 1.4
Packeta v1.4
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / CurrencySwitcherFacade.php

CurrencySwitcherFacade.php in Packeta 1.4, at src/Packetery/Module/CurrencySwitcherFacade.php

66 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class CurrencySwitcherFacade
4 *
5 * @package Packetery\Module
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Module;
11
12 /**
13 * Class CurrencySwitcherFacade.
14 */
15 class CurrencySwitcherFacade {
16
17 /**
18 * List of supported plugins for options export.
19 *
20 * @var string[]
21 */
22 public static $supportedCurrencySwitchers = [
23 'WOOCS - WooCommerce Currency Switcher',
24 ];
25
26 /**
27 * Applies currency conversion if needed.
28 *
29 * @param float $price Price to convert.
30 *
31 * @return float
32 */
33 public function getConvertedPrice( float $price ): float {
34 if ( Helper::isPluginActive( 'woocommerce-currency-switcher/index.php' ) ) {
35 return $this->applyFilterWoocsExchangeValue( $price );
36 }
37
38 /**
39 * Applies packetery_price filters.
40 *
41 * @since 1.4
42 */
43 return (float) apply_filters( 'packetery_price', $price );
44 }
45
46 /**
47 * WooCommerce currency-switcher.com compatibility. Does no harm in case WOOCS is not active.
48 *
49 * @param float $value Value of the surcharge or transport price.
50 *
51 * @return float
52 */
53 private function applyFilterWoocsExchangeValue( float $value ): float {
54 if ( 0 < $value ) {
55 /**
56 * Applies woocs_exchange_value filters.
57 *
58 * @since 1.2.7
59 */
60 $value = (float) apply_filters( 'woocs_exchange_value', $value );
61 }
62
63 return $value;
64 }
65 }
66