wc_get_price_to_display( WC_Product $product, array $args = array() )

Returns the price including or excluding tax, based on the ‘woocommerce_tax_display_shop’ setting.


Description Description


Parameters Parameters

$product

(WC_Product) (Required) WC_Product object.

$args

(array) (Optional) arguments to pass product quantity and price.

Default value: array()


Top ↑

Return Return

(float)


Top ↑

Source Source

File: includes/wc-product-functions.php

function wc_get_price_to_display( $product, $args = array() ) {
	$args = wp_parse_args(
		$args,
		array(
			'qty'   => 1,
			'price' => $product->get_price(),
		)
	);

	$price = $args['price'];
	$qty   = $args['qty'];

	return 'incl' === get_option( 'woocommerce_tax_display_shop' ) ?
		wc_get_price_including_tax(
			$product,
			array(
				'qty'   => $qty,
				'price' => $price,
			)
		) :
		wc_get_price_excluding_tax(
			$product,
			array(
				'qty'   => $qty,
				'price' => $price,
			)
		);
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.