Filter uncanny-automator

automator_woocommerce_order_summary_container_id

Filters the ID of the WooCommerce order summary container, allowing modification before display.

add_filter( 'automator_woocommerce_order_summary_container_id', $callback, 10, 2 );

Description

Filters the ID of the HTML container used for the WooCommerce order summary within Automator. This allows developers to dynamically change the container ID, enabling custom styling or integration with other scripts that target specific element IDs. It fires when the order summary is being rendered.


Usage

add_filter( 'automator_woocommerce_order_summary_container_id', 'your_function_name', 10, 2 );

Parameters

$order (mixed)
This parameter contains the WooCommerce order object.
$order (mixed)
The `$order` parameter provides the current WooCommerce order object being processed.

Return Value

The filtered value.


Examples

<?php
/**
 * Filters the ID of the order summary container.
 *
 * This filter allows developers to dynamically change the ID attribute of the
 * main container element that wraps the WooCommerce order summary output.
 * This can be useful for various purposes, such as targeted styling or JavaScript manipulation.
 *
 * @param string $container_id The default ID of the container.
 * @param WC_Order $order The WC_Order object.
 * @return string The modified container ID.
 */
add_filter( 'automator_woocommerce_order_summary_container_id', function( $container_id, $order ) {
	// Example: Append the order status to the container ID for unique identification
	// based on status, perhaps for conditional display in certain automations.
	if ( $order instanceof WC_Order ) {
		$status = $order->get_status();
		$container_id .= '-' . sanitize_title( $status );
	}

	return $container_id;
}, 10, 2 );

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:1009

$tr_text_colour   = apply_filters( 'automator_woocommerce_order_summary_tr_text_color', '#636363', $order );
		$td_border_colour = apply_filters( 'automator_woocommerce_order_summary_td_border_color', '#e5e5e5', $order );
		$td_text_colour   = apply_filters( 'automator_woocommerce_order_summary_td_text_color', '#636363', $order );
		
		// Add filters for container styling
		$max_width        = apply_filters( 'automator_woocommerce_order_summary_max_width', '640px', $order );
		$container_class  = apply_filters( 'automator_woocommerce_order_summary_container_class', 'automator-order-summary-container', $order );
		$container_id     = apply_filters( 'automator_woocommerce_order_summary_container_id', 'automator-order-summary-' . $order->get_id(), $order );
		$table_class      = apply_filters( 'automator_woocommerce_order_summary_table_class', 'automator-order-summary-table', $order );

		$html   = array();
		$html[] = sprintf(
			'<div id="%s" class="%s" style="max-width: %s; width: 100%%;">',
			esc_attr( $container_id ),
			esc_attr( $container_class ),


Scroll to Top