Trying to place a custom field after the total section in the checkout page in woocommerce


This code correctly works but does not place the custom field where I want it. In the add_action I would like to use woocommerce_review_order_after_order_total as the location attribute to place it on the page. I got the hook name from this visual guide However this hook breaks my code and gives me the following php error.

Fatal error: Uncaught Error: Call to a member function get_value() on string in /Users/anderskitson/Local Sites/river-cafe/app/public/wp-content/themes/salient-child/functions.php on line 96

Hopefully someone can give me hand. Thanks


* Add custom field to the checkout page


add_action('woocommerce_after_order_notes', 'custom_checkout_field');

/* add_action('woocommerce_review_order_after_order_total', 'custom_checkout_field');*/
/* ^ This is the code that is breaking */ 

function custom_checkout_field($checkout)


echo '<div id="custom_checkout_field"><h2>' . __('New Heading') . '</h2>';

woocommerce_form_field('custom_field_name', array(

'type' => 'text',

'class' => array(

'my-field-class form-row-wide'

) ,

'label' => __('Custom Additional Field') ,

'placeholder' => __('New Custom Field') ,

) ,


echo '</div>';

, , Anders Kitson 4 years 2019-11-05T13:12:01-05:00 0 Answers 86 views 0

Leave an answer