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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
namespace AutomateWoo;
defined( 'ABSPATH' ) || exit;
/** * @class WooCommerce_Payments_Integration * @since 5.5.12 */ class WooCommerce_Payments_Integration {
/** * WooCommerce_Payments_Integration constructor. */ public function __construct() { add_filter( 'automatewoo/actions', array( $this, 'maybe_remove_incompatible_actions' ) ); }
/** * Removes AutomateWoo actions that are incompatible with WooCommerce Payments. * * @param array $actions AutomateWoo actions. * @return array Potentially filtered AutomateWoo actions. */ public function maybe_remove_incompatible_actions( $actions ) { // Subscriptions not enabled, bail. if ( ! Integrations::is_subscriptions_active() ) { return $actions; }
// The WooCommerce Subscriptions extension is active, bail. if ( class_exists( '\WC_Subscriptions' ) ) { return $actions; }
$payment_gateways = WC()->payment_gateways->payment_gateways();
// The WooCommerce Payments payment gateway is not enabled, bail. if ( ! isset( $payment_gateways['woocommerce_payments'] ) || ! isset( $payment_gateways['woocommerce_payments']->enabled ) || 'yes' !== $payment_gateways['woocommerce_payments']->enabled ) { return $actions; }
$wcpay_gateway = $payment_gateways['woocommerce_payments'];
$actions_to_remove = [];
if ( ! $wcpay_gateway->supports( 'subscription_amount_changes' ) ) { $actions_to_remove = array_merge( $actions_to_remove, array( 'subscription_add_coupon', 'subscription_add_product', 'subscription_add_shipping', 'subscription_recalculate_taxes', 'subscription_remove_coupon', 'subscription_remove_product', 'subscription_remove_shipping', 'subscription_update_currency', 'subscription_update_product', 'subscription_update_shipping', ) ); }
if ( ! $wcpay_gateway->supports( 'subscription_date_changes' ) ) { $actions_to_remove = array_merge( $actions_to_remove, array( 'subscription_update_next_payment_date', 'subscription_update_schedule', ) ); }
foreach ( $actions_to_remove as $action_to_remove ) { unset( $actions[ $action_to_remove ] ); }
return $actions; } }
|