Skip to content

Commit

Permalink
New Settings UI: Adjust send-only country message and notices
Browse files Browse the repository at this point in the history
  • Loading branch information
hmouhtar committed Dec 26, 2024
1 parent a398940 commit f92c868
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ static function () use ( $c ) {
return;
}

$current_page_id = $c->get( 'wcgateway.current-ppcp-settings-page-id' );
$is_wc_settings_page = $c->get( 'wcgateway.is-wc-settings-page' );
$messaging_locations = $c->get( 'paylater-configurator.messaging-locations' );
$current_page_id = $c->get( 'wcgateway.current-ppcp-settings-page-id' );
$is_wc_settings_page = $c->get( 'wcgateway.is-wc-settings-page' );
$messaging_locations = $c->get( 'paylater-configurator.messaging-locations' );
$is_current_country_send_only = $c->get( 'wcgateway.is-send-only-country' );

self::add_paylater_update_notice( $messaging_locations, $is_wc_settings_page, $current_page_id );
self::add_paylater_update_notice( $messaging_locations, $is_wc_settings_page, $current_page_id, $is_current_country_send_only );

$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
Expand Down Expand Up @@ -162,12 +163,13 @@ static function () use ( $c ) {
* @param array $message_locations PayLater messaging locations.
* @param bool $is_settings_page Whether the current page is a WC settings page.
* @param string $current_page_id ID of current settings page tab.
* @param bool $is_current_country_send_only Whether the current store's country is classified as a send-only country.
*
* @return void
*/
private static function add_paylater_update_notice( array $message_locations, bool $is_settings_page, string $current_page_id ) : void {
private static function add_paylater_update_notice( array $message_locations, bool $is_settings_page, string $current_page_id, bool $is_current_country_send_only ) : void {
// The message must be registered on any WC-Settings page, except for the Pay Later page.
if ( ! $is_settings_page || Settings::PAY_LATER_TAB_ID === $current_page_id ) {
if ( ! $is_settings_page || Settings::PAY_LATER_TAB_ID === $current_page_id || $is_current_country_send_only ) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { __, sprintf } from '@wordpress/i18n';

const SendOnlyMessage = () => {
return (
<p>
Your current WooCommerce store location is in a "send-only" country,
according to PayPal's policies. Sellers in these countries are
unable to receive payments via PayPal. Since receiving payments is
essential for using the PayPal Payments extension, you will not be
able to connect your PayPal account while operating from a
"send-only" country. To activate PayPal, please update your
WooCommerce store location to a supported region and connect a
PayPal account eligible for receiving payments.
</p>
const url = '/wp-admin/admin.php?page=wc-settings';

const message = sprintf(
/* translators: 1: URL to the WooCommerce store location settings */
__(
'Your current <a href="%1$s">WooCommerce store location</a> is in a "send-only" country, according to PayPal\'s policies. Sellers in these countries are unable to receive payments via PayPal. Since receiving payments is essential for using the PayPal Payments extension, you will not be able to connect your PayPal account while operating from a "send-only" country. To activate PayPal, please update your <a href="%1$s">WooCommerce store location</a> to a supported region and connect a PayPal account eligible for receiving payments.',
'woocommerce-paypal-payments'
),
url
);

return <p dangerouslySetInnerHTML={ { __html: message } } />;
};

export default SendOnlyMessage;

0 comments on commit f92c868

Please sign in to comment.