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.

Метод класса: Notices{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->add_paypal_unsupported_currency_notice(): void;

Список изменений

С версии 10.5.0 Введена.

Код Notices::add_paypal_unsupported_currency_notice() WC 11.0.1

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 );
}