Merge branch 'trunk' of github.com:woocommerce/woocommerce-paypal-payments into PCP-4249-fastlane-add-incompatible-setup-notice

This commit is contained in:
Daniel Dudzic 2025-02-25 16:27:48 +01:00
commit f657676832
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
9 changed files with 68 additions and 61 deletions

View file

@ -63,6 +63,10 @@
&:hover {
transform: rotate(45deg);
}
&.components-button {
height: auto;
}
}
.ppcp--method-icon {
@ -79,6 +83,7 @@
justify-content: space-between;
align-items: center;
margin-top: auto;
min-height: 24px;
}
.ppcp--method-toggle-wrapper {

View file

@ -73,7 +73,6 @@
gap: 8px;
&--save {
margin-top: -4px;
align-items: flex-end;
}
@ -87,7 +86,7 @@
&__field-rows {
display: flex;
flex-direction: column;
gap: 24px;
gap: 18px;
&--acdc {
gap: 18px;
@ -98,19 +97,11 @@
}
.components-radio-control {
.components-flex {
gap: 18px;
}
label {
@include font(14, 20, 400);
color: $color-black;
}
&__option {
gap: 18px;
}
&__input {
border-color: $color-gray-700;
margin-right: 0;

View file

@ -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 );
@ -130,15 +131,18 @@ const DetailsPhysical = () => (
const DetailsSubscriptions = ( { showLink, showNotice } ) => (
<>
{ showLink && (
<a
target="__blank"
href="https://woocommerce.com/document/woocommerce-paypal-payments/#subscriptions-faq"
>
{ __(
'WooCommerce Subscriptions',
'woocommerce-paypal-payments'
) }
</a>
<p
dangerouslySetInnerHTML={ {
__html: sprintf(
/* translators: %s is the URL to the WooCommerce Subscriptions product page */
__(
'* To use subscriptions, you must have <a target="_blank" href="%s">WooCommerce Subscriptions</a> enabled.',
'woocommerce-paypal-payments'
),
'https://woocommerce.com/products/woocommerce-subscriptions/'
),
} }
/>
) }
{ showNotice && (
<p>

View file

@ -59,6 +59,8 @@ export const getSteps = ( flags ) => {
const steps = filterSteps( ALL_STEPS, [
// Casual selling: Unlock the "Personal Account" choice.
( step ) => flags.canUseCasualSelling || step.id !== 'business',
// Skip payment methods screen.
( step ) => ! flags.shouldSkipPaymentMethods || step.id !== 'methods',
] );
const totalStepsCount = steps.length;

View file

@ -100,14 +100,16 @@ const Modal = ( { method, setModalIsVisible, onSave } ) => {
case 'radio':
return (
<>
<strong className="ppcp-r-modal__content-title">
{ field.label }
</strong>
{ field.description && (
<p className="ppcp-r-modal__description">
{ field.description }
</p>
) }
<div className="ppcp-r-modal__field-row">
<strong className="ppcp-r-modal__content-title">
{ field.label }
</strong>
{ field.description && (
<span className="ppcp-r-modal__field-description">
{ field.description }
</span>
) }
</div>
<div className="ppcp-r-modal__field-row">
<RadioControl
selected={ settings[ key ] }

View file

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

View file

@ -68,18 +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();
// Card payments are disabled for this plugin when WooPayments is active.
// TODO: Move this condition to the card-fields.eligible service?
if ( class_exists( '\WC_Payments' ) ) {
$can_use_card_payments = false;
}
$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
$can_use_subscriptions,
$should_skip_payment_methods
);
},
'settings.data.general' => static function ( ContainerInterface $container ) : GeneralSettings {

View file

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

View file

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