WC_Product::get_price_suffix
Get the suffix to display after prices > 0.
Method of the class: WC_Product{}
Hooks from the method
Returns
String.
Usage
$WC_Product = new WC_Product(); $WC_Product->get_price_suffix( $price, $qty );
- $price(string)
- to calculate, left blank to just use get_price().
Default:'' - $qty(int)
- passed on to get_price_including_tax() or get_price_excluding_tax().
Default:1
WC_Product::get_price_suffix() WC Product::get price suffix code WC 10.5.0
public function get_price_suffix( $price = '', $qty = 1 ) {
$html = '';
$suffix = get_option( 'woocommerce_price_display_suffix' );
if ( $suffix && wc_tax_enabled() && ProductTaxStatus::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 );
}