WC_Product_Variable_Data_Store_CPT::taxes_influence_priceprotectedWC 10.4.0

Check if the prices for a product will be different with or without taxes.

Method of the class: WC_Product_Variable_Data_Store_CPT{}

Returns

true|false. True if the prices will be different with or without taxes.

Usage

// protected - for code of main (parent) or child class
$result = $this->taxes_influence_price( $product ): bool;
$product(WC_Product) (required)
Product to check.

Changelog

Since 10.4.0 Introduced.

WC_Product_Variable_Data_Store_CPT::taxes_influence_price() code WC 11.0.1

protected function taxes_influence_price( $product ): bool {
	if ( ! $product->is_taxable() ) {
		$taxes_influence_price = false;
	} elseif ( empty( WC_Tax::get_rates( $product->get_tax_class() ) ) ) {
		$taxes_influence_price = false;
	} else {
		// Taxes influence the price regardless of VAT exempt status. Even when a
		// customer is VAT exempt, the displayed prices differ from non-exempt
		// prices, so they need separate cache entries and the opposite_price_hash
		// optimization should not apply. Returning false here was causing cached
		// non-exempt prices to be served to VAT exempt customers.
		$taxes_influence_price = true;
	}

	/**
	 * Filters whether taxes influence the displayed price of a variable product.
	 *
	 * Return `true` from this filter to force separate cache entries for the two
	 * variants. This is needed when an extension produces displayed prices that
	 * differ from raw prices independently of the standard tax calculation, for
	 * example when computing per-country prices for locations that have no
	 * configured tax rates.
	 *
	 * @param bool       $taxes_influence_price Default decision based on product taxability and configured tax rates.
	 * @param WC_Product $product               The variable product being evaluated.
	 *
	 * @since 10.9.0
	 */
	return (bool) apply_filters( 'woocommerce_variable_product_taxes_influence_price', $taxes_influence_price, $product );
}