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, [ const steps = filterSteps( ALL_STEPS, [
// Casual selling: Unlock the "Personal Account" choice. // Casual selling: Unlock the "Personal Account" choice.
( step ) => flags.canUseCasualSelling || step.id !== 'business', ( step ) => flags.canUseCasualSelling || step.id !== 'business',
// Hide methods screen when WooPayments is active. // Skip payment methods screen.
( step ) => ! flags.isWooPaymentsActive || step.id !== 'methods', ( step ) => ! flags.shouldSkipPaymentMethods || step.id !== 'methods',
] ); ] );
const totalStepsCount = steps.length; const totalStepsCount = steps.length;

View file

@ -23,7 +23,7 @@ const defaultTransient = Object.freeze( {
canUseVaulting: false, canUseVaulting: false,
canUseCardPayments: false, canUseCardPayments: false,
canUseSubscriptions: 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_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' ) $can_use_subscriptions = $container->has( 'wc-subscriptions.helper' ) && $container->get( 'wc-subscriptions.helper' )
->plugin_is_active(); ->plugin_is_active();
$is_woopayments_active = class_exists( '\WC_Payments' ); $should_skip_payment_methods = class_exists( '\WC_Payments' );
return new OnboardingProfile( return new OnboardingProfile(
$can_use_casual_selling, $can_use_casual_selling,
$can_use_vaulting, $can_use_vaulting,
$can_use_card_payments, $can_use_card_payments,
$can_use_subscriptions, $can_use_subscriptions,
$is_woopayments_active $should_skip_payment_methods
); );
}, },
'settings.data.general' => static function ( ContainerInterface $container ) : GeneralSettings { '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_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_card_payments Whether credit card payments are possible.
* @param bool $can_use_subscriptions Whether WC Subscriptions plugin is active. * @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. * @throws RuntimeException If the OPTION_KEY is not defined in the child class.
*/ */
@ -52,15 +52,15 @@ class OnboardingProfile extends AbstractDataModel {
bool $can_use_vaulting = false, bool $can_use_vaulting = false,
bool $can_use_card_payments = false, bool $can_use_card_payments = false,
bool $can_use_subscriptions = false, bool $can_use_subscriptions = false,
bool $is_woopayments_active = false bool $should_skip_payment_methods = false
) { ) {
parent::__construct(); parent::__construct();
$this->flags['can_use_casual_selling'] = $can_use_casual_selling; $this->flags['can_use_casual_selling'] = $can_use_casual_selling;
$this->flags['can_use_vaulting'] = $can_use_vaulting; $this->flags['can_use_vaulting'] = $can_use_vaulting;
$this->flags['can_use_card_payments'] = $can_use_card_payments; $this->flags['can_use_card_payments'] = $can_use_card_payments;
$this->flags['can_use_subscriptions'] = $can_use_subscriptions; $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

@ -68,20 +68,20 @@ class OnboardingRestEndpoint extends RestEndpoint {
* @var array * @var array
*/ */
private array $flag_map = array( private array $flag_map = array(
'can_use_casual_selling' => array( 'can_use_casual_selling' => array(
'js_name' => 'canUseCasualSelling', 'js_name' => 'canUseCasualSelling',
), ),
'can_use_vaulting' => array( 'can_use_vaulting' => array(
'js_name' => 'canUseVaulting', 'js_name' => 'canUseVaulting',
), ),
'can_use_card_payments' => array( 'can_use_card_payments' => array(
'js_name' => 'canUseCardPayments', 'js_name' => 'canUseCardPayments',
), ),
'can_use_subscriptions' => array( 'can_use_subscriptions' => array(
'js_name' => 'canUseSubscriptions', 'js_name' => 'canUseSubscriptions',
), ),
'is_woopayments_active' => array( 'should_skip_payment_methods' => array(
'js_name' => 'isWooPaymentsActive', 'js_name' => 'shouldSkipPaymentMethods',
), ),
); );