ckup is chosen separately to shipping in that context. * * @param array $packages Array of shipping packages. * @return array */ public function remove_shipping_if_no_address( $packages ) { if ( 'shortcode' === WC()->cart->cart_context ) { return $packages; } $shipping_cost_requires_address = wc_string_to_bool( get_option( 'woocommerce_shipping_cost_requires_address', 'no' ) ); // Return early here for a small performance gain if we don't need to hide shipping costs until an address is entered. if ( ! $shipping_cost_requires_address ) { return $packages; } $customer = WC()->customer; if ( $customer instanceof WC_Customer && $customer->has_full_shipping_address() ) { return $packages; } return array_map( function ( $package ) { // Package rates is always an array due to a check in core. $package['rates'] = array_filter( $package['rates'], function ( $rate ) { return $rate instanceof WC_Shipping_Rate && in_array( $rate->get_method_id(), LocalPickupUtils::get_local_pickup_method_ids(), true ); } ); return $package; }, $packages ); } /** * Track local pickup settings changes. * * @deprecated 11.0.0 Tracking now happens inside PickupLocationsRestController::update_settings(). * * @param bool $served Whether the request has already been served. * @param \WP_REST_Response $result The response object. * @param \WP_REST_Request $request The request object. * @return bool */ public function track_local_pickup( $served, $result, $request ) { unset( $result, $request ); wc_deprecated_function( __METHOD__, '11.0.0' ); return $served; } /** * Check if legacy local pickup is activated in any of the shipping zones or in the Rest of the World zone. * * @since 8.8.0 * * @return bool */ 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; } }