Support » Plugin: Departamentos y Ciudades de Colombia para Woocommerce » Warning: Invalid argument supplied for foreach()

  • Resolved apagoa

    (@apagoa)


    Hi,

    When I’m log in and at the checkout page this error shows up:

    Warning: Invalid argument supplied for foreach() in /wp-content/plugins/departamentos-y-ciudades-de-colombia-para-woocommerce/woocommerce-states-and-places.php on line 177

    How Can I fix it?

    The dropdowns seem to be working because they show the list of cities.

    Thank you
    ———————————
    Cuando me encuentro logueada y en la página de checkout me aparece el error PHP que menciono arriba. cómo hago para arreglarlo?, los despegables parecen funcionar porque cargan la información.

    • This topic was modified 2 years, 5 months ago by  apagoa.
Viewing 2 replies - 1 through 2 (of 2 total)
  • I think I fixed it, what I did was to add an if statement around the foreach like this, and the warning disappear.

    if($array) {
    	foreach ( $dropdown_places as $city_name ) {
    		if(!is_array($city_name)) {
    			$field .= '<option value="' . esc_attr( $city_name ) . '" '.selected( $value, $city_name, false ) . '>' . $city_name .'</option>';
    		}
    	}
    }
    • This reply was modified 2 years, 5 months ago by  apagoa.

    Thanks a lot, it worked very well!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Warning: Invalid argument supplied for foreach()’ is closed to new replies.