mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
🔀 Merge branch 'trunk'
This commit is contained in:
commit
748c7f4d10
9 changed files with 213 additions and 50 deletions
|
@ -94,6 +94,45 @@ function as_schedule_single_action( $timestamp, $hook, $args = array(), $group =
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the number of times a filter has been applied during the current request.
|
||||||
|
*
|
||||||
|
* @since 6.1.0
|
||||||
|
*
|
||||||
|
* @global int[] $wp_filters Stores the number of times each filter was triggered.
|
||||||
|
*
|
||||||
|
* @param string $hook_name The name of the filter hook.
|
||||||
|
* @return int The number of times the filter hook has been applied.
|
||||||
|
*/
|
||||||
|
function did_filter( $hook_name ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not a filter hook is currently being processed.
|
||||||
|
*
|
||||||
|
* The function current_filter() only returns the most recent filter being executed.
|
||||||
|
* did_filter() returns the number of times a filter has been applied during
|
||||||
|
* the current request.
|
||||||
|
*
|
||||||
|
* This function allows detection for any filter currently being executed
|
||||||
|
* (regardless of whether it's the most recent filter to fire, in the case of
|
||||||
|
* hooks called from hook callbacks) to be verified.
|
||||||
|
*
|
||||||
|
* @since 3.9.0
|
||||||
|
*
|
||||||
|
* @see current_filter()
|
||||||
|
* @see did_filter()
|
||||||
|
* @global string[] $wp_current_filter Current filter.
|
||||||
|
*
|
||||||
|
* @param string|null $hook_name Optional. Filter hook to check. Defaults to null,
|
||||||
|
* which checks if any filter is currently being run.
|
||||||
|
* @return bool Whether the filter is currently in the stack.
|
||||||
|
*/
|
||||||
|
function doing_filter( $hook_name = null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML API: WP_HTML_Tag_Processor class
|
* HTML API: WP_HTML_Tag_Processor class
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -91,9 +91,12 @@ return function ( string $root_dir ): iterable {
|
||||||
$modules[] = ( require "$modules_dir/ppcp-axo-block/module.php" )();
|
$modules[] = ( require "$modules_dir/ppcp-axo-block/module.php" )();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$show_new_ux = '1' === get_option( 'woocommerce-ppcp-is-new-merchant' );
|
||||||
|
$preview_new_ux = '1' === getenv( 'PCP_SETTINGS_ENABLED' );
|
||||||
|
|
||||||
if ( apply_filters(
|
if ( apply_filters(
|
||||||
'woocommerce.feature-flags.woocommerce_paypal_payments.settings_enabled',
|
'woocommerce.feature-flags.woocommerce_paypal_payments.settings_enabled',
|
||||||
getenv( 'PCP_SETTINGS_ENABLED' ) === '1'
|
$show_new_ux || $preview_new_ux
|
||||||
) ) {
|
) ) {
|
||||||
$modules[] = ( require "$modules_dir/ppcp-settings/module.php" )();
|
$modules[] = ( require "$modules_dir/ppcp-settings/module.php" )();
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,16 @@ return array(
|
||||||
$container->get( 'settings.data.settings' ),
|
$container->get( 'settings.data.settings' ),
|
||||||
$subscription_map_helper->map()
|
$subscription_map_helper->map()
|
||||||
),
|
),
|
||||||
|
/**
|
||||||
|
* We need to pass the PaymentSettings model instance to use it in some helpers.
|
||||||
|
* Once the new settings module is permanently enabled,
|
||||||
|
* this model can be passed as a dependency to the appropriate helper classes.
|
||||||
|
* For now, we must pass it this way to avoid errors when the new settings module is disabled.
|
||||||
|
*/
|
||||||
|
new SettingsMap(
|
||||||
|
$container->get( 'settings.data.payment' ),
|
||||||
|
array()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'compat.settings.settings_map_helper' => static function( ContainerInterface $container ) : SettingsMapHelper {
|
'compat.settings.settings_map_helper' => static function( ContainerInterface $container ) : SettingsMapHelper {
|
||||||
|
@ -180,7 +190,8 @@ return array(
|
||||||
$container->get( 'compat.settings.styling_map_helper' ),
|
$container->get( 'compat.settings.styling_map_helper' ),
|
||||||
$container->get( 'compat.settings.settings_tab_map_helper' ),
|
$container->get( 'compat.settings.settings_tab_map_helper' ),
|
||||||
$container->get( 'compat.settings.subscription_map_helper' ),
|
$container->get( 'compat.settings.subscription_map_helper' ),
|
||||||
$container->get( 'compat.settings.general_map_helper' )
|
$container->get( 'compat.settings.general_map_helper' ),
|
||||||
|
$container->get( 'wcgateway.settings.admin-settings-enabled' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'compat.settings.styling_map_helper' => static function() : StylingSettingsMapHelper {
|
'compat.settings.styling_map_helper' => static function() : StylingSettingsMapHelper {
|
||||||
|
|
|
@ -10,7 +10,9 @@ declare( strict_types = 1 );
|
||||||
namespace WooCommerce\PayPalCommerce\Compat\Settings;
|
namespace WooCommerce\PayPalCommerce\Compat\Settings;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\Settings\Data\AbstractDataModel;
|
||||||
use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
|
use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
|
||||||
|
use WooCommerce\PayPalCommerce\Settings\Data\PaymentSettings;
|
||||||
use WooCommerce\PayPalCommerce\Settings\Data\SettingsModel;
|
use WooCommerce\PayPalCommerce\Settings\Data\SettingsModel;
|
||||||
use WooCommerce\PayPalCommerce\Settings\Data\StylingSettings;
|
use WooCommerce\PayPalCommerce\Settings\Data\StylingSettings;
|
||||||
|
|
||||||
|
@ -72,6 +74,13 @@ class SettingsMapHelper {
|
||||||
*/
|
*/
|
||||||
protected GeneralSettingsMapHelper $general_settings_map_helper;
|
protected GeneralSettingsMapHelper $general_settings_map_helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the new settings module is enabled.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected bool $new_settings_module_enabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -80,6 +89,7 @@ class SettingsMapHelper {
|
||||||
* @param SettingsTabMapHelper $settings_tab_map_helper A helper for mapping the old/new settings tab settings.
|
* @param SettingsTabMapHelper $settings_tab_map_helper A helper for mapping the old/new settings tab settings.
|
||||||
* @param SubscriptionSettingsMapHelper $subscription_map_helper A helper for mapping old and new subscription settings.
|
* @param SubscriptionSettingsMapHelper $subscription_map_helper A helper for mapping old and new subscription settings.
|
||||||
* @param GeneralSettingsMapHelper $general_settings_map_helper A helper for mapping old and new general settings.
|
* @param GeneralSettingsMapHelper $general_settings_map_helper A helper for mapping old and new general settings.
|
||||||
|
* @param bool $new_settings_module_enabled Whether the new settings module is enabled.
|
||||||
* @throws RuntimeException When an old key has multiple mappings.
|
* @throws RuntimeException When an old key has multiple mappings.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -87,7 +97,8 @@ class SettingsMapHelper {
|
||||||
StylingSettingsMapHelper $styling_settings_map_helper,
|
StylingSettingsMapHelper $styling_settings_map_helper,
|
||||||
SettingsTabMapHelper $settings_tab_map_helper,
|
SettingsTabMapHelper $settings_tab_map_helper,
|
||||||
SubscriptionSettingsMapHelper $subscription_map_helper,
|
SubscriptionSettingsMapHelper $subscription_map_helper,
|
||||||
GeneralSettingsMapHelper $general_settings_map_helper
|
GeneralSettingsMapHelper $general_settings_map_helper,
|
||||||
|
bool $new_settings_module_enabled
|
||||||
) {
|
) {
|
||||||
$this->validate_settings_map( $settings_map );
|
$this->validate_settings_map( $settings_map );
|
||||||
$this->settings_map = $settings_map;
|
$this->settings_map = $settings_map;
|
||||||
|
@ -95,6 +106,7 @@ class SettingsMapHelper {
|
||||||
$this->settings_tab_map_helper = $settings_tab_map_helper;
|
$this->settings_tab_map_helper = $settings_tab_map_helper;
|
||||||
$this->subscription_map_helper = $subscription_map_helper;
|
$this->subscription_map_helper = $subscription_map_helper;
|
||||||
$this->general_settings_map_helper = $general_settings_map_helper;
|
$this->general_settings_map_helper = $general_settings_map_helper;
|
||||||
|
$this->new_settings_module_enabled = $new_settings_module_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,6 +136,10 @@ class SettingsMapHelper {
|
||||||
* @return mixed|null The value of the mapped setting, or null if not found.
|
* @return mixed|null The value of the mapped setting, or null if not found.
|
||||||
*/
|
*/
|
||||||
public function mapped_value( string $old_key ) {
|
public function mapped_value( string $old_key ) {
|
||||||
|
if ( ! $this->new_settings_module_enabled ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->ensure_map_initialized();
|
$this->ensure_map_initialized();
|
||||||
if ( ! isset( $this->key_to_model[ $old_key ] ) ) {
|
if ( ! isset( $this->key_to_model[ $old_key ] ) ) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -147,6 +163,10 @@ class SettingsMapHelper {
|
||||||
* @return bool True if the key exists in the new settings, false otherwise.
|
* @return bool True if the key exists in the new settings, false otherwise.
|
||||||
*/
|
*/
|
||||||
public function has_mapped_key( string $old_key ) : bool {
|
public function has_mapped_key( string $old_key ) : bool {
|
||||||
|
if ( ! $this->new_settings_module_enabled ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->ensure_map_initialized();
|
$this->ensure_map_initialized();
|
||||||
|
|
||||||
return isset( $this->key_to_model[ $old_key ] );
|
return isset( $this->key_to_model[ $old_key ] );
|
||||||
|
@ -169,7 +189,11 @@ class SettingsMapHelper {
|
||||||
|
|
||||||
switch ( true ) {
|
switch ( true ) {
|
||||||
case $model instanceof StylingSettings:
|
case $model instanceof StylingSettings:
|
||||||
return $this->styling_settings_map_helper->mapped_value( $old_key, $this->model_cache[ $model_id ] );
|
return $this->styling_settings_map_helper->mapped_value(
|
||||||
|
$old_key,
|
||||||
|
$this->model_cache[ $model_id ],
|
||||||
|
$this->get_payment_settings_model()
|
||||||
|
);
|
||||||
|
|
||||||
case $model instanceof GeneralSettings:
|
case $model instanceof GeneralSettings:
|
||||||
return $this->general_settings_map_helper->mapped_value( $old_key, $this->model_cache[ $model_id ] );
|
return $this->general_settings_map_helper->mapped_value( $old_key, $this->model_cache[ $model_id ] );
|
||||||
|
@ -217,4 +241,23 @@ class SettingsMapHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the PaymentSettings model instance.
|
||||||
|
*
|
||||||
|
* Once the new settings module is permanently enabled,
|
||||||
|
* this model can be passed as a dependency to the appropriate helper classes.
|
||||||
|
* For now, we must pass it this way to avoid errors when the new settings module is disabled.
|
||||||
|
*
|
||||||
|
* @return AbstractDataModel|null
|
||||||
|
*/
|
||||||
|
protected function get_payment_settings_model() : ?AbstractDataModel {
|
||||||
|
foreach ( $this->settings_map as $settings_map_instance ) {
|
||||||
|
if ( $settings_map_instance->get_model() instanceof PaymentSettings ) {
|
||||||
|
return $settings_map_instance->get_model();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,11 @@ declare(strict_types=1);
|
||||||
namespace WooCommerce\PayPalCommerce\Compat\Settings;
|
namespace WooCommerce\PayPalCommerce\Compat\Settings;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\Applepay\ApplePayGateway;
|
||||||
use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
|
use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
|
||||||
|
use WooCommerce\PayPalCommerce\Googlepay\GooglePayGateway;
|
||||||
|
use WooCommerce\PayPalCommerce\Settings\Data\AbstractDataModel;
|
||||||
|
use WooCommerce\PayPalCommerce\Settings\Data\PaymentSettings;
|
||||||
use WooCommerce\PayPalCommerce\Settings\DTO\LocationStylingDTO;
|
use WooCommerce\PayPalCommerce\Settings\DTO\LocationStylingDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +27,7 @@ class StylingSettingsMapHelper {
|
||||||
|
|
||||||
use ContextTrait;
|
use ContextTrait;
|
||||||
|
|
||||||
protected const BUTTON_NAMES = array( 'ppcp-googlepay', 'ppcp-applepay', 'pay-later' );
|
protected const BUTTON_NAMES = array( GooglePayGateway::ID, ApplePayGateway::ID, 'pay-later' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps old setting keys to new setting style names.
|
* Maps old setting keys to new setting style names.
|
||||||
|
@ -66,10 +70,11 @@ class StylingSettingsMapHelper {
|
||||||
*
|
*
|
||||||
* @param string $old_key The key from the legacy settings.
|
* @param string $old_key The key from the legacy settings.
|
||||||
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
||||||
|
* @param AbstractDataModel|null $payment_settings The payment settings model.
|
||||||
*
|
*
|
||||||
* @return mixed The value of the mapped setting, (null if not found).
|
* @return mixed The value of the mapped setting, (null if not found).
|
||||||
*/
|
*/
|
||||||
public function mapped_value( string $old_key, array $styling_models ) {
|
public function mapped_value( string $old_key, array $styling_models, ?AbstractDataModel $payment_settings ) {
|
||||||
switch ( $old_key ) {
|
switch ( $old_key ) {
|
||||||
case 'smart_button_locations':
|
case 'smart_button_locations':
|
||||||
return $this->mapped_smart_button_locations_value( $styling_models );
|
return $this->mapped_smart_button_locations_value( $styling_models );
|
||||||
|
@ -81,16 +86,16 @@ class StylingSettingsMapHelper {
|
||||||
return $this->mapped_pay_later_button_locations_value( $styling_models );
|
return $this->mapped_pay_later_button_locations_value( $styling_models );
|
||||||
|
|
||||||
case 'disable_funding':
|
case 'disable_funding':
|
||||||
return $this->mapped_disabled_funding_value( $styling_models );
|
return $this->mapped_disabled_funding_value( $styling_models, $payment_settings );
|
||||||
|
|
||||||
case 'googlepay_button_enabled':
|
case 'googlepay_button_enabled':
|
||||||
return $this->mapped_button_enabled_value( $styling_models, 'ppcp-googlepay' );
|
return $this->mapped_button_enabled_value( $styling_models, GooglePayGateway::ID, $payment_settings );
|
||||||
|
|
||||||
case 'applepay_button_enabled':
|
case 'applepay_button_enabled':
|
||||||
return $this->mapped_button_enabled_value( $styling_models, 'ppcp-applepay' );
|
return $this->mapped_button_enabled_value( $styling_models, ApplePayGateway::ID, $payment_settings );
|
||||||
|
|
||||||
case 'pay_later_button_enabled':
|
case 'pay_later_button_enabled':
|
||||||
return $this->mapped_button_enabled_value( $styling_models, 'pay-later' );
|
return $this->mapped_button_enabled_value( $styling_models, 'pay-later', $payment_settings );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
foreach ( $this->locations_map() as $old_location_name => $new_location_name ) {
|
foreach ( $this->locations_map() as $old_location_name => $new_location_name ) {
|
||||||
|
@ -225,51 +230,79 @@ class StylingSettingsMapHelper {
|
||||||
* Retrieves the mapped disabled funding value from the new settings.
|
* Retrieves the mapped disabled funding value from the new settings.
|
||||||
*
|
*
|
||||||
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
||||||
|
* @param AbstractDataModel|null $payment_settings The payment settings model.
|
||||||
* @return array|null The list of disabled funding, or null if none are disabled.
|
* @return array|null The list of disabled funding, or null if none are disabled.
|
||||||
*/
|
*/
|
||||||
protected function mapped_disabled_funding_value( array $styling_models ): ?array {
|
protected function mapped_disabled_funding_value( array $styling_models, ?AbstractDataModel $payment_settings ): ?array {
|
||||||
|
if ( is_null( $payment_settings ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$disabled_funding = array();
|
$disabled_funding = array();
|
||||||
$locations_to_context_map = $this->current_context_to_new_button_location_map();
|
$locations_to_context_map = $this->current_context_to_new_button_location_map();
|
||||||
$current_context = $locations_to_context_map[ $this->context() ] ?? '';
|
$current_context = $locations_to_context_map[ $this->context() ] ?? '';
|
||||||
|
assert( $payment_settings instanceof PaymentSettings );
|
||||||
|
|
||||||
foreach ( $styling_models as $model ) {
|
foreach ( $styling_models as $model ) {
|
||||||
if ( $model->location !== $current_context || in_array( 'venmo', $model->methods, true ) ) {
|
if ( $model->location === $current_context ) {
|
||||||
continue;
|
if ( ! in_array( 'venmo', $model->methods, true ) || ! $payment_settings->get_venmo_enabled() ) {
|
||||||
}
|
|
||||||
|
|
||||||
$disabled_funding[] = 'venmo';
|
$disabled_funding[] = 'venmo';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $disabled_funding;
|
return $disabled_funding;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the mapped enabled or disabled button value from the new settings.
|
* Retrieves the mapped enabled or disabled button value from the new settings.
|
||||||
*
|
*
|
||||||
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
||||||
* @param string $button_name The button name (see {@link self::BUTTON_NAMES}).
|
* @param string $button_name The button name (see {@link self::BUTTON_NAMES}).
|
||||||
|
* @param AbstractDataModel|null $payment_settings The payment settings model.
|
||||||
* @return int The enabled (1) or disabled (0) state.
|
* @return int The enabled (1) or disabled (0) state.
|
||||||
* @throws RuntimeException If an invalid button name is provided.
|
* @throws RuntimeException If an invalid button name is provided.
|
||||||
*/
|
*/
|
||||||
protected function mapped_button_enabled_value( array $styling_models, string $button_name ): ?int {
|
protected function mapped_button_enabled_value( array $styling_models, string $button_name, ?AbstractDataModel $payment_settings ): ?int {
|
||||||
|
if ( is_null( $payment_settings ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! in_array( $button_name, self::BUTTON_NAMES, true ) ) {
|
if ( ! in_array( $button_name, self::BUTTON_NAMES, true ) ) {
|
||||||
throw new RuntimeException( 'Wrong button name is provided.' );
|
throw new RuntimeException( 'Wrong button name is provided.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$locations_to_context_map = $this->current_context_to_new_button_location_map();
|
$locations_to_context_map = $this->current_context_to_new_button_location_map();
|
||||||
$current_context = $locations_to_context_map[ $this->context() ] ?? '';
|
$current_context = $locations_to_context_map[ $this->context() ] ?? '';
|
||||||
|
assert( $payment_settings instanceof PaymentSettings );
|
||||||
|
|
||||||
foreach ( $styling_models as $model ) {
|
foreach ( $styling_models as $model ) {
|
||||||
if ( ! $model->enabled
|
if ( $model->enabled && $model->location === $current_context ) {
|
||||||
|| $model->location !== $current_context
|
if ( in_array( $button_name, $model->methods, true ) && $payment_settings->is_method_enabled( $button_name ) ) {
|
||||||
|| ! in_array( $button_name, $model->methods, true )
|
return 1;
|
||||||
) {
|
}
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
if ( $current_context === 'classic_checkout' ) {
|
||||||
|
/**
|
||||||
|
* Outputs an inline CSS style that hides the Google Pay gateway (on Classic Checkout)
|
||||||
|
* In case if the button is disabled from the styling settings but the gateway itself is enabled.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
add_action(
|
||||||
|
'woocommerce_paypal_payments_checkout_button_render',
|
||||||
|
static function (): void {
|
||||||
|
?>
|
||||||
|
<style data-hide-gateway='<?php echo esc_attr( GooglePayGateway::ID ); ?>'>
|
||||||
|
.wc_payment_method.payment_method_ppcp-googlepay {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -81,8 +81,8 @@ const GooglePayComponent = ( { isEditing, buttonAttributes } ) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const features = [ 'products' ];
|
const features = [ 'products' ];
|
||||||
|
if ( buttonConfig?.is_enabled ) {
|
||||||
registerExpressPaymentMethod( {
|
registerExpressPaymentMethod( {
|
||||||
name: buttonData.id,
|
name: buttonData.id,
|
||||||
title: `PayPal - ${ buttonData.title }`,
|
title: `PayPal - ${ buttonData.title }`,
|
||||||
description: __(
|
description: __(
|
||||||
|
@ -99,4 +99,5 @@ registerExpressPaymentMethod( {
|
||||||
features,
|
features,
|
||||||
style: [ 'height', 'borderRadius' ],
|
style: [ 'height', 'borderRadius' ],
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
|
|
@ -105,6 +105,12 @@ class PaymentSettings extends AbstractDataModel {
|
||||||
return $this->get_paylater_enabled();
|
return $this->get_paylater_enabled();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
if (
|
||||||
|
! did_filter( 'woocommerce_payment_gateways' )
|
||||||
|
|| doing_filter( 'woocommerce_payment_gateways' )
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$gateway = $this->get_gateway( $method_id );
|
$gateway = $this->get_gateway( $method_id );
|
||||||
|
|
||||||
if ( $gateway ) {
|
if ( $gateway ) {
|
||||||
|
|
|
@ -53,9 +53,19 @@ class SettingsModule implements ServiceModule, ExecutableModule {
|
||||||
* Returns whether the old settings UI should be loaded.
|
* Returns whether the old settings UI should be loaded.
|
||||||
*/
|
*/
|
||||||
public static function should_use_the_old_ui() : bool {
|
public static function should_use_the_old_ui() : bool {
|
||||||
|
// New merchants should never see the legacy UI.
|
||||||
|
$show_new_ux = '1' === get_option( 'woocommerce-ppcp-is-new-merchant' );
|
||||||
|
|
||||||
|
if ( $show_new_ux ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Existing merchants can opt-in to see the new UI.
|
||||||
|
$opt_out_choice = 'yes' === get_option( SwitchSettingsUiEndpoint::OPTION_NAME_SHOULD_USE_OLD_UI );
|
||||||
|
|
||||||
return apply_filters(
|
return apply_filters(
|
||||||
'woocommerce_paypal_payments_should_use_the_old_ui',
|
'woocommerce_paypal_payments_should_use_the_old_ui',
|
||||||
get_option( SwitchSettingsUiEndpoint::OPTION_NAME_SHOULD_USE_OLD_UI ) === 'yes'
|
$opt_out_choice
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,4 +229,21 @@ define( 'PPCP_PAYPAL_BN_CODE', 'Woo_PPCP' );
|
||||||
return class_exists( 'woocommerce' );
|
return class_exists( 'woocommerce' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_action(
|
||||||
|
'woocommerce_paypal_payments_gateway_migrate',
|
||||||
|
/**
|
||||||
|
* Set new merchant flag on plugin install.
|
||||||
|
*
|
||||||
|
* When installing the plugin for the first time, we direct the user to
|
||||||
|
* the new UI without a data migration, and fully hide the legacy UI.
|
||||||
|
*
|
||||||
|
* @param string|false $version String with previous installed plugin version.
|
||||||
|
* Boolean false on first installation on a new site.
|
||||||
|
*/
|
||||||
|
static function ( $version ) {
|
||||||
|
if ( ! $version ) {
|
||||||
|
update_option( 'woocommerce-ppcp-is-new-merchant', '1' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
} )();
|
} )();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue