Filter uncanny-automator

automator_woocommerce_order_summary_show_taxes

Filters whether taxes are displayed on the WooCommerce order summary for automation.

add_filter( 'automator_woocommerce_order_summary_show_taxes', $callback, 10, 1 );

Description

This filter hook controls whether taxes are displayed in the WooCommerce order summary within Uncanny Automator. Developers can return `false` to hide taxes or `true` to show them, allowing customization of order summary content.


Usage

add_filter( 'automator_woocommerce_order_summary_show_taxes', 'your_function_name', 10, 1 );

Parameters

$order (mixed)
This parameter is a boolean value that determines whether taxes should be displayed in the WooCommerce order summary.

Return Value

The filtered value.


Examples

/**
 * Example of how to use the automator_woocommerce_order_summary_show_taxes filter.
 * This example adds a custom condition to only show taxes if the order total is over a certain amount.
 */
add_filter( 'automator_woocommerce_order_summary_show_taxes', 'my_automator_show_taxes_conditionally', 10, 2 );

function my_automator_show_taxes_conditionally( $show_taxes, $order ) {
	// Ensure we have a valid WooCommerce order object.
	if ( ! $order instanceof WC_Order ) {
		return $show_taxes;
	}

	// Define a threshold for showing taxes.
	$tax_display_threshold = 50; // Show taxes only if the order total is greater than 50.

	// Get the order total.
	$order_total = $order->get_total();

	// Check if the order total meets the threshold.
	if ( $order_total > $tax_display_threshold ) {
		return true; // Show taxes.
	}

	// Otherwise, do not show taxes.
	return false;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/integrations/woocommerce/tokens/wc-tokens.php:1091
src/integrations/wholesale-suite/tokens/wss-tokens.php:718
uncanny-automator-pro/src/integrations/woocommerce/tokens/wc-pro-tokens.php:3004

$html[] = '</td>';
			$html[] = $td_right;
			$html[] = $order->get_subtotal_to_display();
			$html[] = '</td>';
			$html[] = '</tr>';
		}
		// Tax
		if ( true === apply_filters( 'automator_woocommerce_order_summary_show_taxes', true, $order ) ) {
			if ( ! empty( $order->get_taxes() ) ) {
				$html[] = '<tr>';
				$html[] = $td;
				$html[] = apply_filters( 'automator_woocommerce_order_summary_tax_title', esc_attr__( 'Tax:', 'uncanny-automator' ) );
				$html[] = '</td>';
				$html[] = $td_right;
				$html[] = wc_price( $order->get_total_tax() );


Scroll to Top