Add feature-flag for the working capital.

Is turned off by default
This commit is contained in:
Narek Zakarian 2025-08-04 18:48:04 +04:00
parent d7a45138ff
commit 05e24ea0a9
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -966,6 +966,21 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
add_action(
'admin_init',
static function () use ( $container ): void {
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
$is_working_capital_feature_flag_enabled = apply_filters(
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- feature flags use this convention
'woocommerce.feature-flags.woocommerce_paypal_payments.working_capital_enabled',
getenv( 'PCP_WORKING_CAPITAL_ENABLED' ) === '1'
);
$is_working_capital_eligible = $container->get( 'api.shop.country' ) === 'US' && $settings->has( 'stay_updated' ) && $settings->get( 'stay_updated' );
if ( ! $is_working_capital_feature_flag_enabled || ! $is_working_capital_eligible ) {
return;
}
$logger = $container->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
try {