mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #3153 from woocommerce/PCP-4248-show-subscriptions-box-for-business-account-but-disabled
Update the logic to show the subscription box even when the plugin is disabled (4248)
This commit is contained in:
commit
758419c980
1 changed files with 31 additions and 27 deletions
|
@ -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 );
|
||||||
|
@ -130,15 +131,18 @@ const DetailsPhysical = () => (
|
||||||
const DetailsSubscriptions = ( { showLink, showNotice } ) => (
|
const DetailsSubscriptions = ( { showLink, showNotice } ) => (
|
||||||
<>
|
<>
|
||||||
{ showLink && (
|
{ showLink && (
|
||||||
<a
|
<p
|
||||||
target="__blank"
|
dangerouslySetInnerHTML={ {
|
||||||
href="https://woocommerce.com/document/woocommerce-paypal-payments/#subscriptions-faq"
|
__html: sprintf(
|
||||||
>
|
/* translators: %s is the URL to the WooCommerce Subscriptions product page */
|
||||||
{ __(
|
__(
|
||||||
'WooCommerce Subscriptions',
|
'* To use subscriptions, you must have <a target="_blank" href="%s">WooCommerce Subscriptions</a> enabled.',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
),
|
||||||
</a>
|
'https://woocommerce.com/products/woocommerce-subscriptions/'
|
||||||
|
),
|
||||||
|
} }
|
||||||
|
/>
|
||||||
) }
|
) }
|
||||||
{ showNotice && (
|
{ showNotice && (
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue