Rename conditional property

This commit is contained in:
Emili Castells Guasch 2025-02-25 14:50:09 +01:00
parent 2bcef52025
commit fa60a38c22
5 changed files with 18 additions and 18 deletions

View file

@ -59,8 +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',
// Skip payment methods screen.
( step ) => ! flags.shouldSkipPaymentMethods || step.id !== 'methods',
] );
const totalStepsCount = steps.length;

View file

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

View file

@ -68,14 +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();
$is_woopayments_active = class_exists( '\WC_Payments' );
$should_skip_payment_methods = class_exists( '\WC_Payments' );
return new OnboardingProfile(
$can_use_casual_selling,
$can_use_vaulting,
$can_use_card_payments,
$can_use_subscriptions,
$is_woopayments_active
$should_skip_payment_methods
);
},
'settings.data.general' => static function ( ContainerInterface $container ) : GeneralSettings {

View file

@ -43,7 +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.
* @param bool $should_skip_payment_methods Whether it should skip payment methods screen.
*
* @throws RuntimeException If the OPTION_KEY is not defined in the child class.
*/
@ -52,7 +52,7 @@ class OnboardingProfile extends AbstractDataModel {
bool $can_use_vaulting = false,
bool $can_use_card_payments = false,
bool $can_use_subscriptions = false,
bool $is_woopayments_active = false
bool $should_skip_payment_methods = false
) {
parent::__construct();
@ -60,7 +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;
$this->flags['should_skip_payment_methods'] = $should_skip_payment_methods;
}
/**

View file

@ -80,8 +80,8 @@ class OnboardingRestEndpoint extends RestEndpoint {
'can_use_subscriptions' => array(
'js_name' => 'canUseSubscriptions',
),
'is_woopayments_active' => array(
'js_name' => 'isWooPaymentsActive',
'should_skip_payment_methods' => array(
'js_name' => 'shouldSkipPaymentMethods',
),
);