Automattic\WooCommerce\Blocks\Shipping

ShippingController::is_legacy_local_pickup_active()public staticWC 8.8.0

Check if legacy local pickup is activated in any of the shipping zones or in the Rest of the World zone.

Method of the class: ShippingController{}

No Hooks.

Return

true|false.

Usage

$result = ShippingController::is_legacy_local_pickup_active();

Changelog

Since 8.8.0 Introduced.

ShippingController::is_legacy_local_pickup_active() code WC 9.2.3

public static function is_legacy_local_pickup_active() {
	$rest_of_the_world                          = \WC_Shipping_Zones::get_zone_by( 'zone_id', 0 );
	$shipping_zones                             = \WC_Shipping_Zones::get_zones();
	$rest_of_the_world_data                     = $rest_of_the_world->get_data();
	$rest_of_the_world_data['shipping_methods'] = $rest_of_the_world->get_shipping_methods();
	array_unshift( $shipping_zones, $rest_of_the_world_data );

	foreach ( $shipping_zones as $zone ) {
		foreach ( $zone['shipping_methods'] as $method ) {
			if ( 'local_pickup' === $method->id && $method->is_enabled() ) {
				return true;
			}
		}
	}

	return false;
}