Merge pull request #3405 from woocommerce/PCP-4254-inbox-classic-ux-mexico-installments-new-ux-updates

Add Mexico installments notice in Classic UX and WooCommerce Inbox notifications
This commit is contained in:
Emili Castells 2025-05-22 17:16:35 +02:00 committed by GitHub
commit 2e710bbed6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 201 additions and 28 deletions

View file

@ -7,6 +7,8 @@
* Enhancement - Enhance the accessibility of the new Settings UI #3294 * Enhancement - Enhance the accessibility of the new Settings UI #3294
* Enhancement - Add capture pre-conditions for card payment source #3300 * Enhancement - Add capture pre-conditions for card payment source #3300
* Enhancement - Enable all/Disable all toggle next to Alternative Payment methods on Payment Methods tab #3321 * Enhancement - Enable all/Disable all toggle next to Alternative Payment methods on Payment Methods tab #3321
* Enhancement - Add installment notifications for Mexico store locations #3404, #3405
* Fix - Various issues for Mexico store locations during onboarding & plugin configuration #3403
* Fix - APFS plugin triggers incorrect renewal date for simple products as subscriptions #3272 * Fix - APFS plugin triggers incorrect renewal date for simple products as subscriptions #3272
* Fix - PayPal Smart Button incompatible with WooCommerce Subscription Switching #3291 * Fix - PayPal Smart Button incompatible with WooCommerce Subscription Switching #3291
* Fix - Fastlane gateway visible on Pay for Order page #3293 * Fix - Fastlane gateway visible on Pay for Order page #3293

View file

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\AdminNotices; namespace WooCommerce\PayPalCommerce\AdminNotices;
use WooCommerce\PayPalCommerce\AdminNotices\Notes\MexicoInstallmentsNote;
use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository; use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule;
@ -110,6 +111,16 @@ class AdminNotices implements ServiceModule, ExtendingModule, ExecutableModule {
} }
); );
add_action(
'woocommerce_init',
function() {
if ( is_admin() && is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) {
MexicoInstallmentsNote::init();
}
}
);
return true; return true;
} }
} }

View file

@ -0,0 +1,122 @@
<?php
/**
* Inbox Note for Mexico Installments feature.
*
* @package WooCommerce\PayPalCommerce\AdminNotices\Notes
*/
declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\AdminNotices\Notes;
use Automattic\WooCommerce\Admin\Notes\Note;
use Automattic\WooCommerce\Admin\Notes\NotesUnavailableException;
use Automattic\WooCommerce\Admin\Notes\NoteTraits;
use Exception;
/**
* Class MexicoInstallmentsNote
*/
class MexicoInstallmentsNote {
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'ppcp-mexico-installments-note';
/**
* Note initialization.
*/
public static function init(): void {
try {
/**
* The method exists in the NoteTraits trait.
*
* @psalm-suppress UndefinedMethod
*/
self::possibly_add_note();
} catch ( Exception $e ) {
return;
}
}
/**
* Add the note if it passes predefined conditions.
*
* @throws NotesUnavailableException Throws exception when notes are unavailable.
*/
public static function possibly_add_note(): void {
$note = self::get_note();
if ( ! self::can_be_added() ) {
return;
}
$note->save();
}
/**
* Returns a new Note.
*
* @return Note
*/
public static function get_note(): Note {
$note = new Note();
$note->set_name( self::NOTE_NAME );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_source( 'woocommerce-paypal-payments' );
$note->set_title(
__( 'Enable Installments with PayPal', 'woocommerce-paypal-payments' )
);
$note->set_content(
sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag. %3$s and %4$s are the opening and closing of HTML <p> tag.
__(
'Allow your customers to pay in installments without interest while you receive the full payment in a single transaction.*
%3$sActivate your Installments without interest with PayPal.%4$s
%3$sYou will receive the full payment minus the applicable PayPal fee. See %1$sterms and conditions%2$s.%4$s',
'woocommerce-paypal-payments'
),
'<a href="https://www.paypal.com/mx/webapps/mpp/merchant-fees" target="_blank">',
'</a>',
'<p>',
'</p>'
)
);
$note->add_action(
'enable-installments-action-link',
__( 'Enable Installments', 'woocommerce-paypal-payments' ),
esc_url( 'https://www.paypal.com/businessmanage/preferences/installmentplan' ),
Note::E_WC_ADMIN_NOTE_UNACTIONED,
true
);
return $note;
}
/**
* Checks if a note can and should be added.
*
* @return bool
* @throws NotesUnavailableException Throws exception when notes are unavailable.
*/
public static function can_be_added(): bool {
$country = wc_get_base_location()['country'] ?? '';
if ( $country !== 'MX' ) {
return false;
}
/**
* The method exists in the NoteTraits trait.
*
* @psalm-suppress UndefinedMethod
*/
if ( self::note_exists() ) {
return false;
}
return true;
}
}

View file

@ -692,7 +692,7 @@ return array(
assert( $dcc_configuration instanceof CardPaymentsConfiguration ); assert( $dcc_configuration instanceof CardPaymentsConfiguration );
$fields = array( $fields = array(
'checkout_settings_heading' => array( 'checkout_settings_heading' => array(
'heading' => __( 'Standard Payments Settings', 'woocommerce-paypal-payments' ), 'heading' => __( 'Standard Payments Settings', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'screens' => array( 'screens' => array(
@ -702,7 +702,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'title' => array( 'title' => array(
'title' => __( 'Title', 'woocommerce-paypal-payments' ), 'title' => __( 'Title', 'woocommerce-paypal-payments' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'description' => __(
@ -718,7 +718,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'dcc_block_checkout_notice' => array( 'dcc_block_checkout_notice' => array(
'heading' => '', 'heading' => '',
'html' => $container->get( 'wcgateway.notice.checkout-blocks' ), 'html' => $container->get( 'wcgateway.notice.checkout-blocks' ),
'type' => 'ppcp-html', 'type' => 'ppcp-html',
@ -729,7 +729,7 @@ return array(
'requirements' => array( 'dcc' ), 'requirements' => array( 'dcc' ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'dcc_enabled' => array( 'dcc_enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ), 'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'Once enabled, the Credit Card option will show up in the checkout.', 'woocommerce-paypal-payments' ), 'description' => __( 'Once enabled, the Credit Card option will show up in the checkout.', 'woocommerce-paypal-payments' ),
@ -744,7 +744,7 @@ return array(
State::STATE_ONBOARDED, State::STATE_ONBOARDED,
), ),
), ),
'dcc_gateway_title' => array( 'dcc_gateway_title' => array(
'title' => __( 'Title', 'woocommerce-paypal-payments' ), 'title' => __( 'Title', 'woocommerce-paypal-payments' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'description' => __(
@ -761,7 +761,7 @@ return array(
), ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'description' => array( 'description' => array(
'title' => __( 'Description', 'woocommerce-paypal-payments' ), 'title' => __( 'Description', 'woocommerce-paypal-payments' ),
'type' => 'text', 'type' => 'text',
'desc_tip' => true, 'desc_tip' => true,
@ -780,7 +780,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'intent' => array( 'intent' => array(
'title' => __( 'Intent', 'woocommerce-paypal-payments' ), 'title' => __( 'Intent', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
@ -802,7 +802,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'capture_on_status_change' => array( 'capture_on_status_change' => array(
'title' => __( 'Capture On Status Change', 'woocommerce-paypal-payments' ), 'title' => __( 'Capture On Status Change', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'default' => false, 'default' => false,
@ -819,7 +819,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'capture_for_virtual_only' => array( 'capture_for_virtual_only' => array(
'title' => __( 'Capture Virtual-Only Orders ', 'woocommerce-paypal-payments' ), 'title' => __( 'Capture Virtual-Only Orders ', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'default' => false, 'default' => false,
@ -836,7 +836,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'payee_preferred' => array( 'payee_preferred' => array(
'title' => __( 'Instant Payments ', 'woocommerce-paypal-payments' ), 'title' => __( 'Instant Payments ', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'default' => false, 'default' => false,
@ -853,7 +853,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'brand_name' => array( 'brand_name' => array(
'title' => __( 'Brand Name', 'woocommerce-paypal-payments' ), 'title' => __( 'Brand Name', 'woocommerce-paypal-payments' ),
'type' => 'text', 'type' => 'text',
'default' => get_bloginfo( 'name' ), 'default' => get_bloginfo( 'name' ),
@ -869,7 +869,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'landing_page' => array( 'landing_page' => array(
'title' => __( 'Landing Page', 'woocommerce-paypal-payments' ), 'title' => __( 'Landing Page', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
@ -891,7 +891,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'alternative_payment_methods' => array( 'alternative_payment_methods' => array(
'heading' => __( 'Alternative Payment Methods', 'woocommerce-paypal-payments' ), 'heading' => __( 'Alternative Payment Methods', 'woocommerce-paypal-payments' ),
'description' => sprintf( 'description' => sprintf(
// translators: %1$s, %2$s, %3$s and %4$s are a link tags. // translators: %1$s, %2$s, %3$s and %4$s are a link tags.
@ -907,7 +907,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'disable_funding' => array( 'disable_funding' => array(
'title' => __( 'Disable Alternative Payment Methods', 'woocommerce-paypal-payments' ), 'title' => __( 'Disable Alternative Payment Methods', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect', 'type' => 'ppcp-multiselect',
'class' => array(), 'class' => array(),
@ -931,7 +931,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'card_billing_data_mode' => array( 'card_billing_data_mode' => array(
'title' => __( 'Send checkout billing data to card fields', 'woocommerce-paypal-payments' ), 'title' => __( 'Send checkout billing data to card fields', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'class' => array(), 'class' => array(),
@ -951,7 +951,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => array( 'paypal', CardButtonGateway::ID ), 'gateway' => array( 'paypal', CardButtonGateway::ID ),
), ),
'allow_card_button_gateway' => array( 'allow_card_button_gateway' => array(
'title' => __( 'Create gateway for Standard Card Button', 'woocommerce-paypal-payments' ), 'title' => __( 'Create gateway for Standard Card Button', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'desc_tip' => true, 'desc_tip' => true,
@ -965,7 +965,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'allow_local_apm_gateways' => array( 'allow_local_apm_gateways' => array(
'title' => __( 'Create gateway for alternative payment methods', 'woocommerce-paypal-payments' ), 'title' => __( 'Create gateway for alternative payment methods', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'desc_tip' => true, 'desc_tip' => true,
@ -979,7 +979,7 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'disable_cards' => array( 'disable_cards' => array(
'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ), 'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect', 'type' => 'ppcp-multiselect',
'class' => array(), 'class' => array(),
@ -1007,7 +1007,7 @@ return array(
), ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'card_icons' => array( 'card_icons' => array(
'title' => __( 'Show logo of the following credit cards', 'woocommerce-paypal-payments' ), 'title' => __( 'Show logo of the following credit cards', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect', 'type' => 'ppcp-multiselect',
'class' => array(), 'class' => array(),
@ -1046,7 +1046,7 @@ return array(
), ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'dcc_name_on_card' => array( 'dcc_name_on_card' => array(
'title' => __( 'Cardholder Name', 'woocommerce-paypal-payments' ), 'title' => __( 'Cardholder Name', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'default' => $dcc_configuration->show_name_on_card(), 'default' => $dcc_configuration->show_name_on_card(),
@ -1060,7 +1060,7 @@ return array(
'gateway' => array( 'dcc', 'axo' ), 'gateway' => array( 'dcc', 'axo' ),
'requirements' => array( 'axo' ), 'requirements' => array( 'axo' ),
), ),
'3d_secure_heading' => array( '3d_secure_heading' => array(
'heading' => __( '3D Secure', 'woocommerce-paypal-payments' ), 'heading' => __( '3D Secure', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'description' => wp_kses_post( 'description' => wp_kses_post(
@ -1088,7 +1088,7 @@ return array(
), ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'3d_secure_contingency' => array( '3d_secure_contingency' => array(
'title' => __( 'Contingency for 3D Secure', 'woocommerce-paypal-payments' ), 'title' => __( 'Contingency for 3D Secure', 'woocommerce-paypal-payments' ),
'type' => 'select', 'type' => 'select',
'description' => sprintf( 'description' => sprintf(
@ -1116,7 +1116,7 @@ return array(
), ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'saved_payments_heading' => array( 'saved_payments_heading' => array(
'heading' => __( 'Saved Payments', 'woocommerce-paypal-payments' ), 'heading' => __( 'Saved Payments', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'description' => wp_kses_post( 'description' => wp_kses_post(
@ -1143,7 +1143,7 @@ return array(
), ),
'gateway' => 'dcc', 'gateway' => 'dcc',
), ),
'vault_enabled_dcc' => array( 'vault_enabled_dcc' => array(
'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ), 'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'desc_tip' => true, 'desc_tip' => true,
@ -1162,7 +1162,38 @@ return array(
'gateway' => 'dcc', 'gateway' => 'dcc',
'input_class' => $container->get( 'wcgateway.helper.vaulting-scope' ) ? array() : array( 'ppcp-disabled-checkbox' ), 'input_class' => $container->get( 'wcgateway.helper.vaulting-scope' ) ? array() : array( 'ppcp-disabled-checkbox' ),
), ),
'paypal_saved_payments' => array( 'mexico_installments' => array(
'heading' => __( 'Installments', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag. %3$s and %4$s are the opening and closing of HTML <p> tag.
__(
'Allow your customers to pay in installments without interest while you receive the full payment in a single transaction.*
%3$sTerms and conditions: *You will receive the full payment minus the applicable PayPal fee. See %1$sterms and conditions%2$s.%4$s',
'woocommerce-paypal-payments'
),
'<a href="https://www.paypal.com/mx/webapps/mpp/merchant-fees" target="_blank">',
'</a>',
'<p class="description">',
'</p>'
),
),
'mexico_installments_action_link' => array(
'title' => __( 'Activate your Installments', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-text',
'text' => '<a href="https://www.paypal.com/businessmanage/preferences/installmentplan" target="_blank" class="button ppcp-refresh-feature-status">' . esc_html__( 'Enable Installments', 'woocommerce-paypal-payments' ) . '</a>',
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'paypal_saved_payments' => array(
'heading' => __( 'Saved payments', 'woocommerce-paypal-payments' ), 'heading' => __( 'Saved payments', 'woocommerce-paypal-payments' ),
'description' => sprintf( 'description' => sprintf(
// translators: %1$s, %2$s, %3$s and %4$s are a link tags. // translators: %1$s, %2$s, %3$s and %4$s are a link tags.
@ -1180,8 +1211,8 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'subscriptions_mode' => $container->get( 'wcgateway.settings.fields.subscriptions_mode' ), 'subscriptions_mode' => $container->get( 'wcgateway.settings.fields.subscriptions_mode' ),
'vault_enabled' => array( 'vault_enabled' => array(
'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ), 'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'desc_tip' => true, 'desc_tip' => true,
@ -1200,7 +1231,7 @@ return array(
'gateway' => 'paypal', 'gateway' => 'paypal',
'input_class' => $container->get( 'wcgateway.helper.vaulting-scope' ) ? array() : array( 'ppcp-disabled-checkbox' ), 'input_class' => $container->get( 'wcgateway.helper.vaulting-scope' ) ? array() : array( 'ppcp-disabled-checkbox' ),
), ),
'digital_wallet_heading' => array( 'digital_wallet_heading' => array(
'heading' => __( 'Digital Wallet Services', 'woocommerce-paypal-payments' ), 'heading' => __( 'Digital Wallet Services', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading', 'type' => 'ppcp-heading',
'description' => wp_kses_post( 'description' => wp_kses_post(
@ -1255,6 +1286,11 @@ return array(
$fields['disable_cards']['options'] = $card_options; $fields['disable_cards']['options'] = $card_options;
$fields['card_icons']['options'] = array_merge( $dark_versions, $card_options ); $fields['card_icons']['options'] = array_merge( $dark_versions, $card_options );
if ( $container->get( 'api.shop.country' ) !== 'MX' ) {
unset( $fields['mexico_installments'] );
unset( $fields['mexico_installments_action_link'] );
}
return $fields; return $fields;
}, },

View file

@ -163,6 +163,8 @@ If you encounter issues with the PayPal buttons not appearing after an update, p
* Enhancement - Enhance the accessibility of the new Settings UI #3294 * Enhancement - Enhance the accessibility of the new Settings UI #3294
* Enhancement - Add capture pre-conditions for card payment source #3300 * Enhancement - Add capture pre-conditions for card payment source #3300
* Enhancement - Enable all/Disable all toggle next to Alternative Payment methods on Payment Methods tab #3321 * Enhancement - Enable all/Disable all toggle next to Alternative Payment methods on Payment Methods tab #3321
* Enhancement - Add installment notifications for Mexico store locations #3404, #3405
* Fix - Various issues for Mexico store locations during onboarding & plugin configuration #3403
* Fix - APFS plugin triggers incorrect renewal date for simple products as subscriptions #3272 * Fix - APFS plugin triggers incorrect renewal date for simple products as subscriptions #3272
* Fix - PayPal Smart Button incompatible with WooCommerce Subscription Switching #3291 * Fix - PayPal Smart Button incompatible with WooCommerce Subscription Switching #3291
* Fix - Fastlane gateway visible on Pay for Order page #3293 * Fix - Fastlane gateway visible on Pay for Order page #3293