Update the logic to show the subscription box.

The Subscription box should be visible even if the plugin is not activated. It should be disabled.
This commit is contained in:
Narek Zakarian 2025-02-25 17:44:40 +04:00
parent 326ac452be
commit fc5760e518
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -1,4 +1,4 @@
import { __ } from '@wordpress/i18n'; import { __, sprintf } from '@wordpress/i18n';
import { useEffect, useState } from '@wordpress/element'; import { useEffect, useState } from '@wordpress/element';
import { OptionSelector } from '../../../ReusableComponents/Fields'; import { OptionSelector } from '../../../ReusableComponents/Fields';
@ -14,23 +14,24 @@ const StepProducts = () => {
useEffect( () => { useEffect( () => {
const initChoices = () => { const initChoices = () => {
if ( optionState === canUseSubscriptions ) { const choices = productChoicesFull.map( ( choice ) => {
return; if (
} choice.value === PRODUCT_TYPES.SUBSCRIPTIONS &&
! canUseSubscriptions
let choices = productChoicesFull; ) {
return {
// Remove subscription details, if not available. ...choice,
if ( ! canUseSubscriptions ) { isDisabled: true,
choices = choices.filter( contents: (
( { value } ) => value !== PRODUCT_TYPES.SUBSCRIPTIONS <DetailsSubscriptions
); showLink={ true }
setProducts( showNotice={ isCasualSeller }
products.filter( />
( value ) => value !== PRODUCT_TYPES.SUBSCRIPTIONS ),
) };
); }
} return choice;
} );
setProductChoices( choices ); setProductChoices( choices );
setOptionState( canUseSubscriptions ); setOptionState( canUseSubscriptions );