Skip to content

Commit 7a230ec

Browse files
authored
Merge pull request #3531 from woocommerce/PCP-5010-appswitch-flag
Add feature flag for AppSwitch (5010)
2 parents 12c21c5 + 4acdda7 commit 7a230ec

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

modules/ppcp-blocks/resources/js/Components/paypal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ export const PayPalComponent = ( {
401401
const shouldEnableAppSwitch = () => {
402402
// AppSwitch should only be enabled in Pay Now flows with server side shipping callback.
403403
return (
404+
config.scriptData.appswitch.enabled &&
404405
! config.scriptData.final_review_enabled &&
405406
config.scriptData.server_side_shipping_callback.enabled
406407
);

modules/ppcp-button/resources/js/modules/Renderer/Renderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ class Renderer {
252252
shouldEnableAppSwitch = () => {
253253
// AppSwitch should only be enabled in Pay Now flows with server side shipping callback.
254254
return (
255+
this.defaultSettings.appswitch.enabled &&
255256
! this.defaultSettings.final_review_enabled &&
256257
this.defaultSettings.server_side_shipping_callback.enabled
257258
);

modules/ppcp-button/services.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function get_context(): string {
169169
$container->get( 'woocommerce.logger.woocommerce' ),
170170
$container->get( 'button.handle-shipping-in-paypal' ),
171171
$container->get( 'wcgateway.server-side-shipping-callback-enabled' ),
172+
$container->get( 'wcgateway.appswitch-enabled' ),
172173
$container->get( 'button.helper.disabled-funding-sources' ),
173174
$container->get( 'wcgateway.configuration.card-configuration' ),
174175
$container->get( 'api.helper.partner-attribution' ),

modules/ppcp-button/src/Assets/SmartButton.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ class SmartButton implements SmartButtonInterface {
259259
*/
260260
private bool $server_side_shipping_callback_enabled;
261261

262+
/**
263+
* Whether the AppSwitch is enabled (feature flag).
264+
*/
265+
private bool $appswitch_enabled;
266+
262267
/**
263268
* Whether the final review is enabled in blocks settings.
264269
*/
@@ -291,6 +296,7 @@ class SmartButton implements SmartButtonInterface {
291296
* @param LoggerInterface $logger The logger.
292297
* @param bool $should_handle_shipping_in_paypal Whether the shipping should be handled in PayPal.
293298
* @param bool $server_side_shipping_callback_enabled Whether the server-side shipping callback is enabled (feature flag).
299+
* @param bool $appswitch_enabled Whether the AppSwitch is enabled (feature flag).
294300
* @param DisabledFundingSources $disabled_funding_sources List of funding sources to be disabled.
295301
* @param CardPaymentsConfiguration $dcc_configuration The DCC Gateway Configuration.
296302
* @param PartnerAttribution $partner_attribution The PayPal Partner Attribution Helper.
@@ -321,6 +327,7 @@ public function __construct(
321327
LoggerInterface $logger,
322328
bool $should_handle_shipping_in_paypal,
323329
bool $server_side_shipping_callback_enabled,
330+
bool $appswitch_enabled,
324331
DisabledFundingSources $disabled_funding_sources,
325332
CardPaymentsConfiguration $dcc_configuration,
326333
PartnerAttribution $partner_attribution,
@@ -350,6 +357,7 @@ public function __construct(
350357
$this->payment_tokens_endpoint = $payment_tokens_endpoint;
351358
$this->should_handle_shipping_in_paypal = $should_handle_shipping_in_paypal;
352359
$this->server_side_shipping_callback_enabled = $server_side_shipping_callback_enabled;
360+
$this->appswitch_enabled = $appswitch_enabled;
353361
$this->disabled_funding_sources = $disabled_funding_sources;
354362
$this->dcc_configuration = $dcc_configuration;
355363
$this->partner_attribution = $partner_attribution;
@@ -1365,6 +1373,9 @@ public function script_data(): array {
13651373
'server_side_shipping_callback' => array(
13661374
'enabled' => $this->server_side_shipping_callback_enabled,
13671375
),
1376+
'appswitch' => array(
1377+
'enabled' => $this->appswitch_enabled,
1378+
),
13681379
'needShipping' => $this->need_shipping(),
13691380
'vaultingEnabled' => $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ),
13701381
'productType' => null,

modules/ppcp-wc-gateway/services.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,4 +2265,12 @@ static function( ContainerInterface $container ): DisplayManager {
22652265
getenv( 'PCP_SERVER_SIDE_SHIPPING_CALLBACK_ENABLED' ) === '1'
22662266
);
22672267
},
2268+
2269+
'wcgateway.appswitch-enabled' => static function( ContainerInterface $container ) : bool {
2270+
return apply_filters(
2271+
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2272+
'woocommerce.feature-flags.woocommerce_paypal_payments.appswitch_enabled',
2273+
getenv( 'PCP_APPSWITCH_ENABLED' ) === '1'
2274+
);
2275+
},
22682276
);

0 commit comments

Comments
 (0)