Output Woocommerce['order_comments']

Morning Everyone,

So I’m trying to output the Order Comments field box on Multi-Step checkout system.

I have the code below

if ( ! function_exists( 'wmsc_step_content_message' ) ) { 

    function wmsc_step_content_message( $fields = array()) {

        foreach( $fields as $field) {

                echo  $field['order'];



add_action( 'wmsc_step_content_message', 'wmsc_step_content_message' );
    add_filter( 'woocommerce_checkout_fields', 'wmsc_step_content_message' );

However, when I run this, I get the following error:

Invalid argument supplied for foreach() on Line 745

Where am I going wrong?

Any help would be brill.

Thank you.

I notice the code has
$fields = array()

What happens if something other than null or an array are passed to wmsc_step_content_message ?


I’ve tried passing a variable with “Hello World” within this, and echoing it in the function.

Nothing happens.

However if I write echo “Hello Word”; this is outputted without an issue.

Code below:

if ( ! function_exists( ‘wmsc_step_content_message’ ) ) {

$h = "hello world";

function wmsc_step_content_message( $h ) {

    echo $h;
    echo "Hello World";


add_action( ‘wmsc_step_content_message’, ‘wmsc_step_content_message’ );

Not sure if I’ve done the passing correctly.


Evening Everyone,

Just to update you all, this is now working, and was able to achieve what I was looking, plus expand it a little further so it shows in the wp-admin area.

My solution was:

function bdm_personalise_text( $checkout ) { 

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

    woocommerce_form_field('personal_message', array(

        'type'  => 'textarea',
        'class' => array( 'my-field-class form-row-wide' ),
        'label' => __('Your Message'),
        'placeholder' =>  __(''),



    echo '</div>';

add_action( 'wmsc_step_content_message', 'bdm_personalise_text');

Tested this and appears to be working.

Always open to any improvements you’d make to the code. :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.