Filter
uncanny-automator
automator_woocommerce_order_summary_max_width
Filters the maximum width of the WooCommerce order summary.
add_filter( 'automator_woocommerce_order_summary_max_width', $callback, 10, 1 );
Description
Filters the maximum width of the WooCommerce order summary displayed in automator actions. Developers can modify this to control the visual layout of order details in emails or other outputs. Defaults to '640px'.
Usage
add_filter( 'automator_woocommerce_order_summary_max_width', 'your_function_name', 10, 1 );
Parameters
-
$order(mixed) - This parameter sets the maximum width for the order summary in WooCommerce, defaulting to '640px'.
Return Value
The filtered value.
Examples
/**
* Adjust the maximum width of the WooCommerce order summary displayed in automator emails.
*
* This filter allows you to control the maximum width of the order summary table,
* ensuring it displays well on different screen sizes or fits within specific email templates.
*
* @param string $max_width The default maximum width in CSS format (e.g., '640px').
* @param WC_Order $order The current WooCommerce order object.
* @return string The modified maximum width.
*/
add_filter( 'automator_woocommerce_order_summary_max_width', function( $max_width, $order ) {
// Get the user's preference for order summary width if available.
// This is just an example; in a real scenario, you might check user meta,
// a plugin setting, or the order itself for custom width preferences.
$user_meta_width = get_user_meta( get_current_user_id(), 'automator_order_summary_preferred_width', true );
if ( ! empty( $user_meta_width ) && is_string( $user_meta_width ) && str_ends_with( $user_meta_width, 'px' ) ) {
// If a user preference is found, use it.
return $user_meta_width;
}
// Otherwise, return the default or a modified version of the default.
// For demonstration, let's make it smaller for mobile-first designs if the order total is small.
if ( $order->get_total() < 50 ) {
return '480px';
}
// Return the original or a different default if no specific logic applies.
return $max_width; // Or return '768px'; for a slightly larger default.
}, 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:1007
$border_colour = apply_filters( 'automator_woocommerce_order_summary_border_color', '#eee', $order );
$tr_border_colour = apply_filters( 'automator_woocommerce_order_summary_tr_border_color', '#e5e5e5', $order );
$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%%;">',
Internal Usage
Found in src/integrations/woocommerce/tokens/wc-tokens.php:984:
* add_filter( 'automator_woocommerce_order_summary_max_width', function( $width, $order ) {