Automattic\WooCommerce\Gateways\PayPal

Notices::add_paypal_unsupported_currency_noticeprivateWC 10.5.0

Add notice warning when PayPal does not support the store's currency.

Method of the class: Notices{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->add_paypal_unsupported_currency_notice(): void;

Changelog

Since 10.5.0 Introduced.

Notices::add_paypal_unsupported_currency_notice() code WC 10.7.0

private function add_paypal_unsupported_currency_notice(): void {
	$currency = get_woocommerce_currency();

	// Skip if the currency is supported by PayPal.
	if ( $this->gateway->is_valid_for_use() ) {
		return;
	}

	// Skip if the notice has been dismissed.
	if ( $this->is_notice_dismissed( self::PAYPAL_UNSUPPORTED_CURRENCY_NOTICE ) ) {
		return;
	}

	$dismiss_url = $this->get_dismiss_url( self::PAYPAL_UNSUPPORTED_CURRENCY_NOTICE );
	$message     = sprintf(
		/* translators: %s: Currency code */
		esc_html__( 'PayPal Standard does not support your store currency (%s).', 'woocommerce' ),
		$currency
	);

	$notice_html = '<div class="notice notice-error is-dismissible">'
		. '<a class="woocommerce-message-close notice-dismiss" style="text-decoration: none;" href="' . esc_url( $dismiss_url ) . '" aria-label="' . esc_attr__( 'Dismiss this notice', 'woocommerce' ) . '"></a>'
		. '<p>' . $message . '</p>'
		. '</div>';

	echo wp_kses_post( $notice_html );
}