Automattic\WooCommerce\StoreApi\Utilities

CartController::enable_local_pickup_without_address()publicWC 1.0

We want to make local pickup always avaiable without checking for a shipping zone or address.

Метод класса: CartController{}

Хуков нет.

Возвращает

Массив. $shipping_methods Shipping methods with local pickup.

Использование

$CartController = new CartController();
$CartController->enable_local_pickup_without_address( $shipping_methods );
$shipping_methods(массив) (обязательный)
Package we're checking against right now.

Код CartController::enable_local_pickup_without_address() WC 7.1.1

public function enable_local_pickup_without_address( $shipping_methods ) {
	$shipping_zones = \WC_Shipping_Zones::get_zones( 'admin' );
	$worldwide_zone = new \WC_Shipping_Zone( 0 );
	$all_methods    = array_map(
		function( $_shipping_zone ) {
			return $_shipping_zone['shipping_methods'];
		},
		$shipping_zones
	);
	$all_methods    = array_merge_recursive( $worldwide_zone->get_shipping_methods( false, 'admin' ), ...$all_methods );
	$local_pickups  = array_filter(
		$all_methods,
		function( $method ) {
			return 'local_pickup' === $method->id;
		}
	);
	return array_merge( $shipping_methods, $local_pickups );
}