WooCommerce Order Email Add SKU

Hi all,

Can anyone tell me how to add SKU’s to the WooCommerce Order Emails? This is what I found to add to the standard Email via the themes(child) funtions.php, however, Bricks overrides this template;

// add SKUs to WooCommerce order emails
function w3p_add_sku_to_wc_emails( $args ) {
$args[‘show_sku’] = true;
return $args;
}
add_filter( ‘woocommerce_email_order_items_args’, ‘w3p_add_sku_to_wc_emails’ );


So, how/where do I make this change to add it to the order email within the Bricks email template?

Thanks.

After further research and testing I have found the solution;

for clarity, I have used code that was written here and here; I know what I need and I know how to implement it, I just don’t have the required knowledge to write it from scratch, so thank you to both authors for original code.

I am using Bricks 1.5.7 and WooCommerce 7.1.0.

I have added the code below to the child theme functions.php file.

/**
 * Adds Sku to the WooCommerce order emails table
 * Uses WooCommerce 2.5 or newer
 *
 * @param string $output the buffered email order items content
 * @param \WC_Order $order
 * @return $output the updated output
 */
function add_sku_woocommerce_emails( $output, $order ) {
	
	// set a flag so we don't recursively call this filter
	static $run = 0;
  
	// if we've already run this filter, bail out
	if ( $run ) {
		return $output;
	}
  
	$args = array(
    'show_sku'      => true,
	);
  
	// increment our flag so we don't run again
	$run++;
  
	// if first run, give WooCommerce the updated table
	return $order->email_order_items_table( $args );
}
add_filter( 'woocommerce_email_order_items_table', 'add_sku_woocommerce_emails', 10, 2 );

/**
 * Change the Sku output to below the item name
 */
function edit_order_item_name( $name ) {
    return $name . '<br />';
}
add_filter( 'woocommerce_order_item_name', 'edit_order_item_name' );