Filter
uncanny-automator
automator_woocommerce_order_summary_table_class
Filters the CSS classes applied to the WooCommerce order summary table on the order confirmation page.
add_filter( 'automator_woocommerce_order_summary_table_class', $callback, 10, 1 );
Description
Filters the CSS class for the WooCommerce order summary table. Developers can use this to customize the table's appearance by adding or modifying classes, allowing for advanced styling of order details within automations.
Usage
add_filter( 'automator_woocommerce_order_summary_table_class', 'your_function_name', 10, 1 );
Parameters
-
$order(mixed) - This parameter contains the default CSS class name applied to the order summary table.
Return Value
The filtered value.
Examples
<?php
/**
* Example: Add a custom class to the WooCommerce order summary table.
* This filter allows you to dynamically add or modify classes based on order details.
*
* @param string $table_class The default table class.
* @param WC_Order $order The current WC_Order object.
* @return string The modified table class.
*/
add_filter(
'automator_woocommerce_order_summary_table_class',
function ( $table_class, $order ) {
// Check if the order is for a specific product, for example.
// Replace '123' with an actual product ID you want to target.
if ( ! empty( $order ) && $order instanceof WC_Order ) {
foreach ( $order->get_items() as $item ) {
if ( $item->get_product_id() === 123 ) {
// Add a custom class if the order contains product with ID 123.
$table_class .= ' product-123-order';
break; // No need to check further items for this order.
}
}
// Add another class based on order status.
$status = $order->get_status();
if ( $status === 'completed' ) {
$table_class .= ' order-completed';
} elseif ( $status === 'processing' ) {
$table_class .= ' order-processing';
}
}
return $table_class;
},
10, // Priority
2 // Accepted arguments: $table_class, $order
);
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:1010
$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 ),
esc_attr( $max_width )