Filter
uncanny-automator
automator_woocommerce_order_summary_font_family
Filters the font family used in the WooCommerce order summary for customization.
add_filter( 'automator_woocommerce_order_summary_font_family', $callback, 10, 1 );
Description
Filters the font family used for order summaries in WooCommerce automations. Developers can dynamically change the font family to match brand guidelines or specific needs. The default is a common sans-serif stack.
Usage
add_filter( 'automator_woocommerce_order_summary_font_family', 'your_function_name', 10, 1 );
Parameters
-
$order(mixed) - This parameter holds a comma-separated string of font family names, with the first being the preferred font and subsequent ones serving as fallbacks.
Return Value
The filtered value.
Examples
/**
* Filters the font family used in the WooCommerce order summary.
*
* This function allows developers to change the default font family
* for elements within the order summary email or other outputs.
*
* @param string $font_family The default font family string.
* @param WC_Order $order The WooCommerce order object.
* @return string The modified font family string.
*/
add_filter( 'automator_woocommerce_order_summary_font_family', function( $font_family, $order ) {
// Example: If the order total is greater than 100, use a different font.
if ( $order && $order->get_total() > 100 ) {
return "'Arial Black', Gadget, sans-serif";
}
// Otherwise, return the default or previously modified font family.
return $font_family;
}, 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:998
src/integrations/wholesale-suite/tokens/wss-tokens.php:639
uncanny-automator-pro/src/integrations/woocommerce/tokens/wc-pro-tokens.php:2925
*
* @param $order
*
* @return string
*/
public function build_summary_style_html( $order ) {
$font_colour = apply_filters( 'automator_woocommerce_order_summary_text_color', '#000', $order );
$font_family = apply_filters( 'automator_woocommerce_order_summary_font_family', "'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif", $order );
$table_styles = apply_filters( 'automator_woocommerce_order_summary_table_style', '', $order );
$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 );