swissChili | f0cbdc3 | 2023-01-05 17:21:38 -0500 | [diff] [blame^] | 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | |
| 6 | class WC_Stripe_Feature_Flags { |
| 7 | const UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME = 'upe_checkout_experience_enabled'; |
| 8 | |
| 9 | /** |
| 10 | * Checks whether UPE "preview" feature flag is enabled. |
| 11 | * This allows the merchant to enable/disable UPE checkout. |
| 12 | * |
| 13 | * @return bool |
| 14 | */ |
| 15 | public static function is_upe_preview_enabled() { |
| 16 | return 'yes' === get_option( '_wcstripe_feature_upe', 'yes' ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Checks whether UPE is enabled. |
| 21 | * |
| 22 | * @return bool |
| 23 | */ |
| 24 | public static function is_upe_checkout_enabled() { |
| 25 | $stripe_settings = get_option( 'woocommerce_stripe_settings', null ); |
| 26 | return ! empty( $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] ) |
| 27 | && 'yes' === $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ]; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Checks whether UPE has been manually disabled by the merchant. |
| 32 | * |
| 33 | * @return bool |
| 34 | */ |
| 35 | public static function did_merchant_disable_upe() { |
| 36 | $stripe_settings = get_option( 'woocommerce_stripe_settings', null ); |
| 37 | return ! empty( $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] ) && 'disabled' === $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ]; |
| 38 | } |
| 39 | } |