Are you looking to insert a new, custom table row between the Subtotal and Shipping Method radio buttons that appear on the cart page? This table might provide valuable information to customers about their shipping details.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
add_action( 'woocommerce_cart_totals_before_shipping', 'ts_show_custom_table_row', 20 ); // Show on cart
add_action( 'woocommerce_review_order_before_shipping', 'ts_show_custom_table_row', 20 ); // Show on checkout
function ts_show_custom_table_row() {
echo ' <tr>
<th>Custom Label</th>
<td>Eco-Offset Fee</td>
</tr>';
}
add_action( 'woocommerce_cart_totals_before_shipping', 'ts_show_custom_table_row', 20 ); // Show on cart
add_action( 'woocommerce_review_order_before_shipping', 'ts_show_custom_table_row', 20 ); // Show on checkout
function ts_show_custom_table_row() {
echo ' <tr>
<th>Custom Label</th>
<td>Eco-Offset Fee</td>
</tr>';
}
add_action( 'woocommerce_cart_totals_before_shipping', 'ts_show_custom_table_row', 20 ); // Show on cart add_action( 'woocommerce_review_order_before_shipping', 'ts_show_custom_table_row', 20 ); // Show on checkout function ts_show_custom_table_row() { echo ' <tr> <th>Custom Label</th> <td>Eco-Offset Fee</td> </tr>'; }
Output
The provided code adds a custom table row displaying a “Custom Label” and “Eco-Offset Fee” above the shipping section on the WooCommerce cart pages.
Alternatively, you can also display custom message for free shipping in WooCommerce based on shipping method options.