blob: 69377bb25b7c3f206be2f52dcc439585bb04d995 [file] [log] [blame]
<?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 ];
}
}