Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add custom field or html to review order table in WooCommerce Checkout
<?php
/* To add custom field in order review table in checkout page, you will have to use some of the hooks listed below.
do_action( 'woocommerce_review_order_before_cart_contents' );
do_action( 'woocommerce_review_order_after_cart_contents' );
do_action( 'woocommerce_review_order_before_shipping' );
do_action( 'woocommerce_review_order_after_shipping' );
do_action( 'woocommerce_review_order_before_order_total' );
do_action( 'woocommerce_review_order_after_order_total' );
So basically if content is passed to any hook in the review-order.php template, then the HTML is duplicated
when the cart order totals are reloaded.
This is because this table is replaced via JS after updating, but if you've inserted non-table content via these hooks
it will be moved out of the table as it's invalid.
All of the action hooks listed need table rows since hooks are within a HTML table/tbody.
*/
add_action( 'woocommerce_review_order_after_order_total', 'checkout_review_order_custom_field' );
function checkout_review_order_custom_field() {
echo '<tr><td>Text here</td><td>';
woocommerce_form_field( 'my_split_checkbox', array(
'type' => 'checkbox',
'class' => array('checkbox_field'),
'label' => __('', 'woocommerce'),
'required' => false,
));
echo '</td></tr>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment