• Resolved Dave

    (@csn123)


    I’ve set up zones and am using ‘Locations not covered by your other zones’ to cover everywhere else in the world. PHP throws a fatal error when using this catch-all fall-back, as the foreach loop is trying to parse an array that doesn’t exist.

    On line 1576, the foreach loop tries to parse the $delivery_zones[$zone_id][‘zone_locations’] variable. The fix I’ve come up with is to wrap this as follows:

    					if (!empty($delivery_zones[$zone_id]['zone_locations']) && is_array($delivery_zones[$zone_id]['zone_locations']) && count($delivery_zones[$zone_id]['zone_locations'])>0) {
    						foreach ((array) $delivery_zones[$zone_id]['zone_locations'] as $zlocation ) {
    							$zone_countries[] = $zlocation->code;
    						}
    					}

    This skips the foreach loop if the default fallback ‘Locations not covered by your other zones’ group is used in WooCommerce.

    I hope this helps others suffering the same problem and hope this code (or similar) is added to the plugin in due course to stop such fatal errors.

Viewing 1 replies (of 1 total)
  • Plugin Author merlinmonmouth

    (@merlinmonmouth)

    Dave

    We really appreciate you chasing that down – I’ll review it and get it in the next release
    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Fatal error when no zone set’ is closed to new replies.