From 05e24ea0a913192e6786406751409cdf1abba33b Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Mon, 4 Aug 2025 18:48:04 +0400 Subject: [PATCH] Add feature-flag for the working capital. Is turned off by default --- modules/ppcp-wc-gateway/src/WCGatewayModule.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index f6d22371f..c39bedbbf 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -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 {