Home » WooCommerce: Add New Row @ Order Totals (Email & Thank-you Page)

WooCommerce: Add New Row @ Order Totals (Email & Thank-you Page)

by Tutor Aspire

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 tutoraspire.com FREE
 * @sourcecode    https://tutoraspire.com/?p=21589
 * @author        Tutor Aspire
 * @compatible    WC 2.6.14, WP 4.7.2, PHP 5.5.9
 */

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

function tutoraspire_add_recurring_row_email( $total_rows, $myorder_obj ) {

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

return $total_rows;
}

You may also like