Skip to content

Commit 5ffd013

Browse files
wjrosaannemirasolCopilotdiegocurbelo
authored
Checking for other BNPL plugins when showing the promotional banner (#4438)
* Checking for other BNPL plugins when showing the promotional banner * Pass list of custom checkout fields * Add the custom data under extensions * Register the extended data and save it * Defer logic to hook for consistency with normal checkout * Add comments * Add support for radio buttons * Perform basic sanitization based on field type * Add action for custom data validation * Update action names * Fix logic for getting standard checkout fields * Add unit test * Specify checkout form name * Respect keys_only param even for block checkout * Remove TODO and add comment * Display all error messages instead of just the first. Co-authored-by: Copilot <[email protected]> * Add more comments * Rename exception code * Remove keys_only support * Update changelog.txt Co-authored-by: Diego Curbelo <[email protected]> * Readme update * Revert unrelated changes * Revert unrelated changes * Reaplying review suggestion + fix lint issues --------- Co-authored-by: Anne Mirasol <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Diego Curbelo <[email protected]>
1 parent 894bb67 commit 5ffd013

File tree

6 files changed

+18
-1
lines changed

6 files changed

+18
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.6.0 - xxxx-xx-xx =
4+
* Fix - Checks if the store has other BNPL extensions installed before displaying the promotional banner
45
* Fix - Correctly notifies customers and merchants of a failed refund and reverts the refunded status
56
* Update - Legacy checkout experience has been deprecated, new checkout experience is now the default for all sites
67
* Fix - Fixes an edge case where the express payment method buttons would not be displayed on the checkout if taxes used to be enabled

client/settings/payment-settings/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export const NEW_CHECKOUT_EXPERIENCE_BANNER = 'new-checkout-experience';
33
export const NEW_CHECKOUT_EXPERIENCE_APMS_BANNER =
44
'new-checkout-experience-apms';
55
export const BNPL_PROMOTION_BANNER = 'bnpl_promotion_banner';
6+
export const BNPL_PROMOTION_BANNER_TARGET_VERSION = '9.7';

client/settings/payment-settings/promotional-banner/__tests__/get-promotional-banner-type.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe( 'getPromotionalBannerType', () => {
3333
it( 'BNPL promotion banner', () => {
3434
global.wc_stripe_settings_params = {
3535
plugin_version: '9.7.0',
36+
has_other_bnpl_plugins: false,
3637
};
3738

3839
const accountData = {

client/settings/payment-settings/promotional-banner/get-promotional-banner-type.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* global wc_stripe_settings_params */
22
import {
33
BNPL_PROMOTION_BANNER,
4+
BNPL_PROMOTION_BANNER_TARGET_VERSION,
45
NEW_CHECKOUT_EXPERIENCE_APMS_BANNER,
56
NEW_CHECKOUT_EXPERIENCE_BANNER,
67
RECONNECT_BANNER,
@@ -40,14 +41,16 @@ export const getPromotionalBannerType = (
4041
isUpeEnabled &&
4142
! hasBNPLEnabled &&
4243
// eslint-disable-next-line camelcase
44+
! wc_stripe_settings_params?.has_other_bnpl_plugins &&
45+
// eslint-disable-next-line camelcase
4346
wc_stripe_settings_params?.plugin_version &&
4447
parseFloat(
4548
// eslint-disable-next-line camelcase
4649
String( wc_stripe_settings_params.plugin_version )
4750
.split( '.' )
4851
.slice( 0, 2 )
4952
.join( '.' )
50-
) >= 9.7
53+
) >= BNPL_PROMOTION_BANNER_TARGET_VERSION
5154
) {
5255
return BNPL_PROMOTION_BANNER;
5356
} else if ( ! isUpeEnabled ) {

includes/admin/class-wc-stripe-settings-controller.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ public function admin_scripts( $hook_suffix ) {
236236
// Show the BNPL promotional banner only if no BNPL payment methods are enabled.
237237
&& ! array_intersect( WC_Stripe_Payment_Methods::BNPL_PAYMENT_METHODS, $enabled_payment_methods );
238238

239+
$has_other_bnpl_plugins_active = false;
240+
$available_payment_gateways = WC()->payment_gateways->payment_gateways;
241+
foreach ( $available_payment_gateways as $gateway ) {
242+
if ( ( 'affirm' === $gateway->id || 'klarna_payments' === $gateway->id ) && 'yes' === $gateway->enabled ) {
243+
$has_other_bnpl_plugins_active = true;
244+
break;
245+
}
246+
}
247+
239248
$params = [
240249
'time' => time(),
241250
'i18n_out_of_sync' => $message,
@@ -257,6 +266,7 @@ public function admin_scripts( $hook_suffix ) {
257266
'is_oc_available' => WC_Stripe_Feature_Flags::is_oc_available(),
258267
'oauth_nonce' => wp_create_nonce( 'wc_stripe_get_oauth_urls' ),
259268
'is_sepa_tokens_enabled' => 'yes' === $this->gateway->get_option( 'sepa_tokens_for_other_methods', 'no' ),
269+
'has_other_bnpl_plugins' => $has_other_bnpl_plugins_active,
260270
];
261271
wp_localize_script(
262272
'woocommerce_stripe_admin',

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
112112

113113
= 9.6.0 - xxxx-xx-xx =
114114

115+
* Fix - Checks if the store has other BNPL extensions installed before displaying the promotional banner
115116
* Fix - Correctly notifies customers and merchants of a failed refund and reverts the refunded status.
116117
* Update - Legacy checkout experience has been deprecated, new checkout experience is now the default for all sites
117118
* Fix - Fixes an edge case where the express payment method buttons would not be displayed on the checkout if taxes used to be enabled

0 commit comments

Comments
 (0)