Expose final review setting, adjust enableAppSwitch logic

This commit is contained in:
Himad M 2025-07-08 11:55:50 -04:00
parent e682f60037
commit 81a944aba8
No known key found for this signature in database
GPG key ID: 5FC769E9888A7B98
4 changed files with 14 additions and 4 deletions

View file

@ -401,7 +401,7 @@ export const PayPalComponent = ( {
const shouldEnableAppSwitch = () => {
// AppSwitch should only be enabled in Pay Now flows with server side shipping callback.
return (
config.scriptData.should_handle_shipping_in_paypal &&
! config.scriptData.final_review_enabled &&
config.scriptData.server_side_shipping_callback.enabled
);
};

View file

@ -252,7 +252,7 @@ class Renderer {
shouldEnableAppSwitch = () => {
// AppSwitch should only be enabled in Pay Now flows with server side shipping callback.
return (
this.defaultSettings.should_handle_shipping_in_paypal &&
! this.defaultSettings.final_review_enabled &&
this.defaultSettings.server_side_shipping_callback.enabled
);
};

View file

@ -171,7 +171,8 @@ return array(
$container->get( 'wcgateway.server-side-shipping-callback-enabled' ),
$container->get( 'button.helper.disabled-funding-sources' ),
$container->get( 'wcgateway.configuration.card-configuration' ),
$container->get( 'api.helper.partner-attribution' )
$container->get( 'api.helper.partner-attribution' ),
$container->get( 'blocks.settings.final_review_enabled' )
);
},
'button.url' => static function ( ContainerInterface $container ): string {

View file

@ -259,6 +259,11 @@ class SmartButton implements SmartButtonInterface {
*/
private bool $server_side_shipping_callback_enabled;
/**
* Whether the final review is enabled in blocks settings.
*/
private bool $final_review_enabled;
/**
* SmartButton constructor.
*
@ -289,6 +294,7 @@ class SmartButton implements SmartButtonInterface {
* @param DisabledFundingSources $disabled_funding_sources List of funding sources to be disabled.
* @param CardPaymentsConfiguration $dcc_configuration The DCC Gateway Configuration.
* @param PartnerAttribution $partner_attribution The PayPal Partner Attribution Helper.
* @param bool $final_review_enabled Whether the final review is enabled in blocks settings.
*/
public function __construct(
string $module_url,
@ -317,7 +323,8 @@ class SmartButton implements SmartButtonInterface {
bool $server_side_shipping_callback_enabled,
DisabledFundingSources $disabled_funding_sources,
CardPaymentsConfiguration $dcc_configuration,
PartnerAttribution $partner_attribution
PartnerAttribution $partner_attribution,
bool $final_review_enabled
) {
$this->module_url = $module_url;
$this->version = $version;
@ -346,6 +353,7 @@ class SmartButton implements SmartButtonInterface {
$this->disabled_funding_sources = $disabled_funding_sources;
$this->dcc_configuration = $dcc_configuration;
$this->partner_attribution = $partner_attribution;
$this->final_review_enabled = $final_review_enabled;
}
/**
@ -1361,6 +1369,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
'vaultingEnabled' => $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ),
'productType' => null,
'manualRenewalEnabled' => $this->subscription_helper->accept_manual_renewals(),
'final_review_enabled' => $this->final_review_enabled,
);
if ( is_product() ) {