Automattic\WooCommerce\StoreApi\Routes\V1\Ucp

AbstractCatalogRoute::currency_warning │ protected │ WC 1.0

Build a non-fatal warning when the requested context currency differs from the store currency.

Catalog amounts are always expressed in the store's own currency; the store performs no FX conversion. When an agent requests a different currency we ignore it for labeling and surface an informational message so the difference is not silently dropped.

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

Хуков нет.

Возвращает

array|null.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->currency_warning( $context, $store_currency );
$context(массив) (обязательный)
Request context.
$store_currency(строка) (обязательный)
Store currency code used for labeling.

Код AbstractCatalogRoute::currency_warning() WC 11.3.0

protected function currency_warning( array $context, string $store_currency ) {
	if ( ! isset( $context['currency'] ) || 0 === strcasecmp( $context['currency'], $store_currency ) ) {
		return null;
	}

	return array(
		'type'         => 'warning',
		'code'         => 'currency_not_supported',
		'content'      => sprintf(
			/* translators: 1: requested currency code, 2: store currency code. */
			__( 'This store only transacts in %2$s and does not convert currencies. Prices are returned in %2$s; the requested currency %1$s was ignored.', 'woocommerce' ),
			$context['currency'],
			$store_currency
		),
		'severity'     => 'recoverable',
		'path'         => '$.context.currency',
		'content_type' => 'plain',
	);
}