Do not display onboarding payment methods screen when woopayments is active

This commit is contained in:
Emili Castells Guasch 2025-02-25 11:46:33 +01:00
parent 7e3463394a
commit cd57bf6add
5 changed files with 13 additions and 8 deletions

View file

@ -59,6 +59,8 @@ export const getSteps = ( flags ) => {
const steps = filterSteps( ALL_STEPS, [
// Casual selling: Unlock the "Personal Account" choice.
( step ) => flags.canUseCasualSelling || step.id !== 'business',
// Hide methods screen when WooPayments is active.
( step ) => ! flags.isWooPaymentsActive || step.id !== 'methods',
] );
const totalStepsCount = steps.length;

View file

@ -23,6 +23,7 @@ const defaultTransient = Object.freeze( {
canUseVaulting: false,
canUseCardPayments: false,
canUseSubscriptions: false,
isWooPaymentsActive: false,
} ),
} );

View file

@ -68,18 +68,14 @@ return array(
$can_use_card_payments = $container->has( 'card-fields.eligible' ) && $container->get( 'card-fields.eligible' );
$can_use_subscriptions = $container->has( 'wc-subscriptions.helper' ) && $container->get( 'wc-subscriptions.helper' )
->plugin_is_active();
// Card payments are disabled for this plugin when WooPayments is active.
// TODO: Move this condition to the card-fields.eligible service?
if ( class_exists( '\WC_Payments' ) ) {
$can_use_card_payments = false;
}
$is_woopayments_active = class_exists( '\WC_Payments' );
return new OnboardingProfile(
$can_use_casual_selling,
$can_use_vaulting,
$can_use_card_payments,
$can_use_subscriptions
$can_use_subscriptions,
$is_woopayments_active
);
},
'settings.data.general' => static function ( ContainerInterface $container ) : GeneralSettings {

View file

@ -43,6 +43,7 @@ class OnboardingProfile extends AbstractDataModel {
* @param bool $can_use_vaulting Whether vaulting is enabled in the store's country.
* @param bool $can_use_card_payments Whether credit card payments are possible.
* @param bool $can_use_subscriptions Whether WC Subscriptions plugin is active.
* @param bool $is_woopayments_active Whether WooPayments plugin is active.
*
* @throws RuntimeException If the OPTION_KEY is not defined in the child class.
*/
@ -50,7 +51,8 @@ class OnboardingProfile extends AbstractDataModel {
bool $can_use_casual_selling = false,
bool $can_use_vaulting = false,
bool $can_use_card_payments = false,
bool $can_use_subscriptions = false
bool $can_use_subscriptions = false,
bool $is_woopayments_active = false
) {
parent::__construct();
@ -58,6 +60,7 @@ class OnboardingProfile extends AbstractDataModel {
$this->flags['can_use_vaulting'] = $can_use_vaulting;
$this->flags['can_use_card_payments'] = $can_use_card_payments;
$this->flags['can_use_subscriptions'] = $can_use_subscriptions;
$this->flags['is_woopayments_active'] = $is_woopayments_active;
}
/**

View file

@ -80,6 +80,9 @@ class OnboardingRestEndpoint extends RestEndpoint {
'can_use_subscriptions' => array(
'js_name' => 'canUseSubscriptions',
),
'is_woopayments_active' => array(
'js_name' => 'isWooPaymentsActive',
),
);
/**