While working for a freelance client, I did some research on the code that generates the “Order Totals” table. This shows on the Thank-you Page and also on the Email Receipt. So, what if we wanted to add a table row to the foot of such table?

Add a new row to the WooCommerce Order Totals table

PHP Snippet: Add Row to Order Totals Table – WooCommerce


/**
 * @snippet       Add Row to Order Totals Table - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=21589
 * @author        Rodolfo Melogli
 * @compatible    WC 2.6.14, WP 4.7.2, PHP 5.5.9
 */

add_filter( 'woocommerce_get_order_item_totals', 'bbloomer_add_recurring_row_email', 10, 2 );

function bbloomer_add_recurring_row_email( $total_rows, $myorder_obj ) {

$total_rows['recurr_not'] = array(
	'label' => __( 'Rec:', 'woocommerce' ),
	'value'	=> 'blabla'
);

return $total_rows;
}

Share:

Leave a Reply