mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
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:
parent
326ac452be
commit
fc5760e518
1 changed files with 19 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
|||
import { __ } from '@wordpress/i18n';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useEffect, useState } from '@wordpress/element';
|
||||
|
||||
import { OptionSelector } from '../../../ReusableComponents/Fields';
|
||||
|
@ -14,23 +14,24 @@ const StepProducts = () => {
|
|||
|
||||
useEffect( () => {
|
||||
const initChoices = () => {
|
||||
if ( optionState === canUseSubscriptions ) {
|
||||
return;
|
||||
}
|
||||
|
||||
let choices = productChoicesFull;
|
||||
|
||||
// Remove subscription details, if not available.
|
||||
if ( ! canUseSubscriptions ) {
|
||||
choices = choices.filter(
|
||||
( { value } ) => value !== PRODUCT_TYPES.SUBSCRIPTIONS
|
||||
);
|
||||
setProducts(
|
||||
products.filter(
|
||||
( value ) => value !== PRODUCT_TYPES.SUBSCRIPTIONS
|
||||
)
|
||||
);
|
||||
}
|
||||
const choices = productChoicesFull.map( ( choice ) => {
|
||||
if (
|
||||
choice.value === PRODUCT_TYPES.SUBSCRIPTIONS &&
|
||||
! canUseSubscriptions
|
||||
) {
|
||||
return {
|
||||
...choice,
|
||||
isDisabled: true,
|
||||
contents: (
|
||||
<DetailsSubscriptions
|
||||
showLink={ true }
|
||||
showNotice={ isCasualSeller }
|
||||
/>
|
||||
),
|
||||
};
|
||||
}
|
||||
return choice;
|
||||
} );
|
||||
|
||||
setProductChoices( choices );
|
||||
setOptionState( canUseSubscriptions );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue