Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit ba59e81

Browse files
authored
Merge pull request #886 from woocommerce/fix-notice
Update PPCP upgrade notice
2 parents d8c94ef + 5180864 commit ba59e81

File tree

4 files changed

+76
-50
lines changed

4 files changed

+76
-50
lines changed

assets/css/admin/ppec-upgrade-notice.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.plugins tr[data-slug=woocommerce-gateway-paypal-express-checkout] th, .plugins tr[data-slug=woocommerce-gateway-paypal-express-checkout] td {
1+
.plugins tr[data-slug=woocommerce-gateway-paypal-express-checkout].hide-border th, .plugins tr[data-slug=woocommerce-gateway-paypal-express-checkout].hide-border td {
22
box-shadow: none !important;
33
}
44

@@ -8,11 +8,9 @@
88
#ppec-migrate-notice .ppec-notice-section {
99
padding: 0 20px;
1010
}
11-
#ppec-migrate-notice .ppec-notice-title {
12-
border-bottom: 1px solid #FFB900;
13-
}
1411
#ppec-migrate-notice .ppec-notice-title p {
15-
line-height: 30px;
12+
padding: 10px 0 0 0;
13+
font-size: 110%;
1614
}
1715
#ppec-migrate-notice .ppec-notice-title p:before {
1816
vertical-align: middle;
@@ -31,6 +29,7 @@
3129
text-decoration: none;
3230
line-height: 34px;
3331
margin-right: 16px;
32+
margin-top: 16px;
3433
}
3534
#ppec-migrate-notice .ppec-notice-buttons a:last-of-type {
3635
margin-right: 0;
@@ -39,6 +38,9 @@
3938
vertical-align: middle;
4039
margin: -2.5px 5px 0 0;
4140
}
41+
#ppec-migrate-notice .ppec-notice-buttons a.dismiss {
42+
float: right;
43+
}
4244
#ppec-migrate-notice .ppec-notice-buttons a.updating-message:before {
4345
-webkit-animation: rotation 2s infinite linear;
4446
animation: rotation 2s infinite linear;
Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,68 @@
11
;(function ( $, window, document ) {
22
'use strict';
33

4-
// Check whether PayPal Payments is installed.
5-
let is_paypal_payments_installed = false,
6-
is_paypal_payments_active = false;
4+
// Plugin rows.
5+
let $notice_row = $( 'tr#ppec-migrate-notice' );
6+
let $ppec_row = $notice_row.prev();
7+
let $ppcp_row = $( 'tr[data-slug="woocommerce-paypal-payments"]' );
78

8-
const targetElement = $( 'tr[data-slug="woocommerce-paypal-payments"]' );
9-
if ( targetElement.length ) {
10-
is_paypal_payments_installed = true;
9+
$ppec_row.toggleClass( 'hide-border', true );
1110

12-
if ( targetElement.hasClass( 'active' ) ) {
13-
is_paypal_payments_active = true;
14-
}
11+
// Check whether PayPal Payments is installed.
12+
let is_paypal_payments_installed = $ppcp_row.length > 0;
13+
let is_paypal_payments_active = is_paypal_payments_installed && $ppcp_row.hasClass( 'active' );
1514

15+
let updateUI = function() {
1616
// Dynamically update plugin activation link to handle plugin folder renames.
17-
let activation_url = $( targetElement ).find( 'span.activate a' ).attr( 'href' );
18-
$( 'a#ppec-activate-paypal-payments' ).attr( 'href', activation_url );
19-
}
20-
21-
// Hide notice/buttons conditionally.
22-
if ( is_paypal_payments_installed && is_paypal_payments_active ) {
23-
$( 'tr#ppec-migrate-notice' ).hide();
24-
} else if ( is_paypal_payments_installed ) {
25-
$( 'a#ppec-install-paypal-payments' ).hide();
26-
} else {
27-
$( 'a#ppec-activate-paypal-payments' ).hide();
28-
}
29-
30-
// Display buttons area
31-
$( '#ppec-migrate-notice .ppec-notice-buttons' ).removeClass( 'hidden' );
17+
if ( is_paypal_payments_installed > 0 ) {
18+
$notice_row.find( 'a#ppec-activate-paypal-payments' ).attr( 'href', $ppcp_row.find( 'span.activate a' ).attr( 'href' ) );
19+
}
20+
21+
// Hide notice/buttons conditionally.
22+
$notice_row.find( 'a#ppec-install-paypal-payments' ).toggle( ! is_paypal_payments_installed );
23+
$notice_row.find( 'a#ppec-activate-paypal-payments' ).toggle( is_paypal_payments_installed && ! is_paypal_payments_active );
24+
25+
// Display buttons area.
26+
$notice_row.find( '.ppec-notice-buttons' ).removeClass( 'hidden' );
27+
};
3228

3329
// Handle delete event for PayPal Payments.
3430
$( document ).on( 'wp-plugin-delete-success', function( event, response ) {
35-
if ( is_paypal_payments_installed && 'woocommerce-paypal-payments' === response.slug ) {
36-
$( 'a#ppec-activate-paypal-payments' ).hide();
37-
$( 'a#ppec-install-paypal-payments' ).show();
31+
if ( 'woocommerce-paypal-payments' === response.slug ) {
32+
is_paypal_payments_installed = false;
33+
is_paypal_payments_active = false;
34+
updateUI();
3835
}
3936
} );
4037

4138
// Change button text when install link is clicked.
42-
$( document ).on( 'click', '#ppec-install-paypal-payments', function( e ) {
39+
$notice_row.find( '#ppec-install-paypal-payments' ).click( function( e ) {
4340
e.preventDefault();
4441
$( this ).addClass( 'updating-message' ).text( 'Installing...' );
4542
const install_link = $( this ).attr('href');
4643
setTimeout( function(){
4744
window.location = install_link;
48-
}, 100 );
49-
});
45+
}, 50 );
46+
} );
47+
48+
// Dismiss button.
49+
$( document).on( 'click', '#ppec-migrate-notice button.notice-dismiss', function( e ) {
50+
$.ajax(
51+
{
52+
url: ajaxurl,
53+
method: 'POST',
54+
data: {
55+
action: 'ppec_dismiss_ppec_upgrade_notice',
56+
_ajax_nonce: $notice_row.attr( 'data-dismiss-nonce' )
57+
},
58+
dataType: 'json',
59+
success: function( res ) {
60+
$ppec_row.removeClass( 'hide-border' );
61+
}
62+
}
63+
);
64+
} );
65+
66+
updateUI();
67+
5068
})( jQuery, window, document );

includes/class-wc-gateway-ppec-plugin.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ public function maybe_run() {
170170
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
171171
add_action( 'wp_ajax_ppec_dismiss_notice_message', array( $this, 'ajax_dismiss_notice' ) );
172172

173-
add_action( 'after_plugin_row_' . plugin_basename( $this->file ), array( $this, 'ppec_upgrade_notice' ), 10, 3 );
173+
// Upgrade notice.
174+
add_action( 'after_plugin_row_' . plugin_basename( $this->file ), array( $this, 'ppec_upgrade_notice' ), 0, 3 );
175+
add_action( 'wp_ajax_ppec_dismiss_ppec_upgrade_notice', array( $this, 'ppec_upgrade_notice_dismiss_ajax' ) );
174176
}
175177

176178
public function bootstrap() {
@@ -506,6 +508,10 @@ public static function needs_shipping() {
506508
* @param string $status Status filter currently applied to the plugin list.
507509
*/
508510
public function ppec_upgrade_notice( $plugin_file, $plugin_data, $status ) {
511+
if ( 'yes' === get_transient( 'ppec-upgrade-notice-dismissed' ) ) {
512+
return;
513+
}
514+
509515
// Load styles & scripts required for the notice.
510516
wp_enqueue_style( 'ppec-upgrade-notice', plugin_dir_url( __DIR__ ) . '/assets/css/admin/ppec-upgrade-notice.css', array(), WC_GATEWAY_PPEC_VERSION );
511517
wp_enqueue_script( 'ppec-upgrade-notice-js', plugin_dir_url( __DIR__ ) . '/assets/js/admin/ppec-upgrade-notice.js', array(), WC_GATEWAY_PPEC_VERSION, false );
@@ -514,6 +520,12 @@ public function ppec_upgrade_notice( $plugin_file, $plugin_data, $status ) {
514520
include_once $this->plugin_path . 'templates/paypal-payments-upgrade-notice.php';
515521
}
516522

523+
public function ppec_upgrade_notice_dismiss_ajax() {
524+
check_ajax_referer( 'ppec-upgrade-notice-dismiss' );
525+
set_transient( 'ppec-upgrade-notice-dismissed', 'yes', MONTH_IN_SECONDS );
526+
wp_send_json_success();
527+
}
528+
517529
/* Deprecated Functions */
518530

519531
/**

templates/paypal-payments-upgrade-notice.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,22 @@
3131
);
3232
?>
3333

34-
<tr class="plugin-update-tr active notice-warning notice-alt" id="ppec-migrate-notice">
34+
<tr class="plugin-update-tr active notice-warning notice-alt" id="ppec-migrate-notice" data-dismiss-nonce="<?php echo esc_attr( wp_create_nonce( 'ppec-upgrade-notice-dismiss' ) ); ?>">
3535
<td colspan="4" class="plugin-update colspanchange">
36-
<div class="update-message notice inline notice-warning notice-alt">
36+
<div class="notice notice-error inline update-message notice-alt is-dismissible">
3737
<div class='ppec-notice-title ppec-notice-section'>
38-
<p>Upgrade to PayPal Payments: the best way to get paid with PayPal and WooCommerce</p>
38+
<p><strong>Action Required: Switch to WooCommerce PayPal Payments</strong></p>
3939
</div>
4040
<div class='ppec-notice-content ppec-notice-section'>
41-
<p><strong>WooCommerce PayPal Payments</strong> is a full-stack solution that offers powerful and flexible payment processing capabilities. Expand your business by connecting with over 370+ million active PayPal accounts around the globe. With PayPal, you can sell in 200+ markets and accept 100+ currencies. Plus, PayPal can automatically identify customer locations and offer country-specific, local payment methods.</p>
42-
43-
<p>Upgrade now and get access to these great features:</p>
44-
45-
<ul>
46-
<li>Give your customers their preferred ways to pay with one checkout solution. Accept <strong>PayPal</strong>, <strong>PayPal Credit</strong>, <strong>Pay Later</strong> options (available in the US, UK, France, and Germany), <strong>credit & debit cards</strong>, and country-specific, <strong>local payment methods</strong> on any device.</li>
47-
<li>Offer subscriptions and accept recurring payments as PayPal is compatible with <a target="_blank" href="https://woocommerce.com/products/woocommerce-subscriptions/"><strong>WooCommerce Subscriptions</strong></a>.</li>
48-
</ul>
41+
<p>As of 1 Sept 2021, PayPal Checkout is officially retired from WooCommerce.com, and support for this product will end as of 1 March 2022.</p>
42+
<p>We highly recommend upgrading to <a href="https://woocommerce.com/products/woocommerce-paypal-payments/" target="_blank">PayPal Payments</a>, the latest, fully supported extension that includes all of the features of PayPal Checkout and more.</p>
4943
</div>
5044
<div class='ppec-notice-buttons ppec-notice-section hidden'>
5145
<?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
52-
<a id="ppec-install-paypal-payments" href="<?php echo $paypal_payments_install_link; ?>" class="button button-primary woocommerce-save-button">Upgrade to PayPal Payments now</a>
46+
<a id="ppec-install-paypal-payments" href="<?php echo $paypal_payments_install_link; ?>" class="button button-primary">Upgrade to PayPal Payments now</a>
5347
<?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
54-
<a id="ppec-activate-paypal-payments" href="<?php echo $paypal_payments_activate_link; ?>" class="button button-primary woocommerce-save-button">Activate PayPal Payments now</a>
55-
<a href="https://woocommerce.com/products/woocommerce-paypal-payments/" target="_blank" class="button woocommerce-save-button">Learn more</a>
48+
<a id="ppec-activate-paypal-payments" href="<?php echo $paypal_payments_activate_link; ?>" class="button button-primary">Activate PayPal Payments now</a>
49+
<a href="https://docs.woocommerce.com/document/woocommerce-paypal-payments/paypal-payments-upgrade-guide/" target="_blank" class="button woocommerce-save-button">Learn more</a>
5650
</div>
5751
</div>
5852
</td>

0 commit comments

Comments
 (0)