1 | <?php |
||
2 | /** |
||
3 | * WooCommerce. |
||
4 | * |
||
5 | * @author Pronamic <[email protected]> |
||
6 | * @copyright 2005-2021 Pronamic |
||
7 | * @license GPL-3.0-or-later |
||
8 | * @package Pronamic\WordPress\Pay |
||
9 | */ |
||
10 | |||
11 | namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay; |
||
12 | |||
13 | use Pronamic\WordPress\Money\Money; |
||
14 | |||
15 | /** |
||
16 | * WooCommerce. |
||
17 | * |
||
18 | * @author Reüel van der Steege |
||
19 | * @since 2.2.0 |
||
20 | * @version 2.2.0 |
||
21 | */ |
||
22 | class WooCommerce { |
||
23 | /** |
||
24 | * Filter WooCommerce available payment gateways. |
||
25 | * |
||
26 | * @param array $gateways Available gateways. |
||
27 | * @return array |
||
28 | */ |
||
29 | public static function woocommerce_available_payment_gateways( $gateways ) { |
||
30 | // Do not filter gateways in admin. |
||
31 | if ( \is_admin() ) { |
||
32 | return $gateways; |
||
33 | } |
||
34 | |||
35 | // Check Santander gateway. |
||
36 | $santander_id = 'pronamic_pay_santander'; |
||
37 | |||
38 | if ( \array_key_exists( $santander_id, $gateways ) ) { |
||
39 | // Check MultiSafepay gateway. |
||
40 | $gateway = $gateways[ $santander_id ]; |
||
41 | |||
42 | $gateway_id = \get_post_meta( (int) $gateway->settings['config_id'], '_pronamic_gateway_id', true ); |
||
43 | |||
44 | $total = new Money( \WC()->cart->get_total( 'raw' ) ); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
45 | |||
46 | // Unset gateway if cart amount minimum not met. |
||
47 | if ( 'multisafepay-connect' === $gateway_id && $total->get_value() < 250 ) { |
||
48 | unset( $gateways[ $santander_id ] ); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | return $gateways; |
||
53 | } |
||
54 | } |
||
55 |