class-wc-stripe-feature-flags.php
1.15 KB
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
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WC_Stripe_Feature_Flags {
const UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME = 'upe_checkout_experience_enabled';
/**
* Checks whether UPE "preview" feature flag is enabled.
* This allows the merchant to enable/disable UPE checkout.
*
* @return bool
*/
public static function is_upe_preview_enabled() {
return 'yes' === get_option( '_wcstripe_feature_upe', 'yes' );
}
/**
* Checks whether UPE is enabled.
*
* @return bool
*/
public static function is_upe_checkout_enabled() {
$stripe_settings = get_option( 'woocommerce_stripe_settings', null );
return ! empty( $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] )
&& 'yes' === $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ];
}
/**
* Checks whether UPE has been manually disabled by the merchant.
*
* @return bool
*/
public static function did_merchant_disable_upe() {
$stripe_settings = get_option( 'woocommerce_stripe_settings', null );
return ! empty( $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] ) && 'disabled' === $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ];
}
}