• Resolved kennoddd

    (@kennoddd)


    Hi, I added 1 custom shipping field (state) to the checkout, and now this error is shown on the checkout page:

    Warning: Invalid argument supplied for foreach() in /home/…/form-shipping.php on line 62

    code is as follows (line 62 is <?php foreach….)

    <div class="woocommerce-additional-fields__field-wrapper">
    			
    <?php foreach ( $checkout->get_checkout_fields( 'order' ) as $key => $field ) : ?>
    <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
    			
    <?php endforeach; ?>	
    </div>

    Please let me know what I can do to solve the error, thanks!

    – Kenneth

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Tomasz WP Desk

    (@tomaszwp)

    Hello @kennoddd

    Our plugin does not have a State field. Please send a screenshot of the settings of this field because I assume that this is a Select field with a list of states.
    Please also write the full path of the form-shipping.php file where this error occurs.

    Thread Starter kennoddd

    (@kennoddd)

    Hi Tomasz,

    Here you go. The state field was created as a text field, so I just need the customers to fill it up. This is the only custom field I created, the only other field I tweaked was town/city to make it required instead of optional.

    full path as follows:

    Warning: Invalid argument supplied for foreach() in /home/secretsa/urchin.fun/wp-content/plugins/woocommerce/templates/checkout/form-shipping.php on line 62

    Plugin Support Tomasz WP Desk

    (@tomaszwp)

    Hello @kennoddd

    I added such a field on a clean installation with the latest version of our FCF plugin and WP/WooCommerce. I do not have a similar error on the website or in the logs.
    Example

    Please make sure the latest versions of FCF and WooCommerce are installed.

    Please let me know what is the reason for adding such a field. The State field is the default field that appears if the user has selected a country that requires a state (e.g. USA).

    Also please write what this point is about.

    The only other field I tweaked was town/city to make it required instead of optional.

    I am asking because this field is checked as required by default so no change is needed to make it required. So I was wondering what the change was.

    Please make sure that the problem is not related to the operation of another plugin because I see that the checkout is divided into steps (our plugin is not compatible with such solutions).

    Troubleshooting steps:

    • Install the HealthCheck plugin.
    • Disable all plugins except WooCommerce and ours.
    • Enable default template like Storefront.
    • See if the error appears.
    Thread Starter kennoddd

    (@kennoddd)

    Hi Tomasz,

    My logistics partner requires that everyone fills up the state fill. The town/city field was also set as optional on my installation by default, not sure why. I was reading that it’s normally a required field from the start, so I’m equally confused.

    I tried using the fluid checkout plugin and now the error doesn’t show up. So I might stick to using that for now. Thanks again for the help!

    Plugin Support Tomasz WP Desk

    (@tomaszwp)

    Hello @kennoddd

    I am sorry I was not able to find the cause.
    I am marking this thread as closed.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Invalid argument supplied for foreach(’ is closed to new replies.