WooCommercePreOrders.php
919 Bytes
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
38
39
40
41
<?php
/**
* Class WooCommercePreOrders
*
* @package WCPay\MultiCurrency\Compatibility
*/
namespace WCPay\MultiCurrency\Compatibility;
use WCPay\MultiCurrency\MultiCurrency;
use WCPay\MultiCurrency\Utils;
/**
* Class that controls Multi Currency Compatibility with WooCommerce Pre-Orders Plugin.
*/
class WooCommercePreOrders extends BaseCompatibility {
/**
* Init the class.
*
* @return void
*/
protected function init() {
// Add needed actions and filters if Pre-Orders is active.
if ( class_exists( 'WC_Pre_Orders' ) ) {
add_filter( 'wc_pre_orders_fee', [ $this, 'wc_pre_orders_fee' ] );
}
}
/**
* Convert the Pre-Orders fee.
*
* @param array $args Array of args for the Pre-Orders fee.
*
* @return array
*/
public function wc_pre_orders_fee( array $args ): array {
$args['amount'] = $this->multi_currency->get_price( $args['amount'], 'product' );
return $args;
}
}