WC_Product::get_price_suffix()publicWC 1.0

Get the suffix to display after prices > 0.

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

Хуки из метода

Возвращает

Строку.

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

$WC_Product = new WC_Product();
$WC_Product->get_price_suffix( $price, $qty );
$price(строка)
to calculate, left blank to just use get_price().
По умолчанию: ''
$qty(int)
passed on to get_price_including_tax() or get_price_excluding_tax().
По умолчанию: 1

Код WC_Product::get_price_suffix() WC 8.7.0

public function get_price_suffix( $price = '', $qty = 1 ) {
	$html = '';

	$suffix = get_option( 'woocommerce_price_display_suffix' );
	if ( $suffix && wc_tax_enabled() && 'taxable' === $this->get_tax_status() ) {
		if ( '' === $price ) {
			$price = $this->get_price();
		}
		$replacements = array(
			'{price_including_tax}' => wc_price( wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), // @phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
			'{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), // @phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
		);
		$html         = str_replace( array_keys( $replacements ), array_values( $replacements ), ' <small class="woocommerce-price-suffix">' . wp_kses_post( $suffix ) . '</small>' );
	}
	return apply_filters( 'woocommerce_get_price_suffix', $html, $this, $price, $qty );
}