lic function register_local_pickup_method( $methods ) { $methods[] = 'pickup_location'; return $methods; } /** * Hides the shipping address on the order confirmation page when local pickup is selected. * * @param array $pickup_methods Method ids. * @return array */ public function hide_shipping_address_for_local_pickup( $pickup_methods ) { return array_merge( $pickup_methods, LocalPickupUtils::get_local_pickup_method_ids() ); } /** * Everytime we save or update local pickup settings, we flush the shipping * transient group. * * @param array $settings The setting array we're saving. * @return array $settings The setting array we're saving. */ public function flush_cache( $settings ) { \WC_Cache_Helper::get_transient_version( 'shipping', true ); return $settings; } /** * Filter the location used for taxes based on the chosen pickup location. * * @param array $address Location args. * @return array */ public function filter_taxable_address( $address ) { if ( null === WC()->session ) { return $address; } // We only need to select from the first package, since pickup_location only supports a single package. $chosen_method = current( WC()->session->get( 'chosen_shipping_methods', array() ) ) ?? ''; $chosen_method_id = explode( ':', $chosen_method )[0]; $chosen_method_instance = explode( ':', $chosen_method )[1] ?? 0; // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment if ( $chosen_method_id && true === apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) && in_array( $chosen_method_id, LocalPickupUtils::get_local_pickup_method_ids(), true ) ) { $pickup_locations = get_option( 'pickup_location_pickup_locations', [] ); $pickup_location = $pickup_locations[ $chosen_method_instance ] ?? []; if ( isset( $pickup_location['address'], $pickup_location['address']['country'] ) && ! empty( $pickup_location['address']['country'] ) ) { $address = array( $pickup_locations[ $chosen_method_instance ]['address']['country'], $pickup_locations[ $chosen_method_instance ]['address']['state'], $pickup_locations[ $chosen_method_instance ]['address']['postcode'], $pickup_locations[ $chosen_method_instance ]['address']['city'], ); } } return $address; } /** * Local Pickup requires all packages to support local pickup. This is because the entire order must be picked up * so that all packages get the same tax rates applied during checkout. * * If a shipping package does not support local pickup (e.g. if disabled by an extension), this filters the option * out for all packages. This will in turn disable the "pickup" toggle in Block Checkout. * * @param array $packages Array of shipping packages. * @return array */ public function filter_shipping_packages( $packages ) { // Check all packages for an instance of a collectable shipping method. $valid_packages = array_filter( $packages, function( $package ) { $shipping_method_ids = ArrayUtil::select( $package['rates'] ?? [], 'get_method_id', ArrayUtil::SELECT_BY_OBJECT_METHOD ); return ! empty( array_intersect( LocalPickupUtils::get_local_pickup_method_ids(), $shipping_method_ids ) ); } ); // Remove pickup location from rates arrays. if ( count( $valid_packages ) !== count( $packages ) ) { $packages = array_map( function( $package ) { if ( ! is_array( $package['rates'] ) ) { $package['rates'] = []; return $package; } $package['rates'] = array_filter( $package['rates'], function( $rate ) { return ! in_array( $rate->get_method_id(), LocalPickupUtils::get_local_pickup_method_ids(), true ); } ); return $package; }, $packages ); } return $packages; } /** * Track local pickup settings changes via Store API * * @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 ) { if ( '/wp/v2/settings' !== $request->get_route() ) { return $served; } // Param name here comes from the show_in_rest['name'] value when registering the setting. if ( ! $request->get_param( 'pickup_location_settings' ) && ! $request->get_param( 'pickup_locations' ) ) { return $served; } $event_name = 'local_pickup_save_changes'; $settings = $request->get_param( 'pickup_location_settings' ); $locations = $request->get_param( 'pickup_locations' ); $data = array( 'local_pickup_enabled' => 'yes' === $settings['enabled'] ? true : false, 'title' => __( 'Local Pickup', 'woocommerce' ) === $settings['title'], 'price' => '' === $settings['cost'] ? true : false, 'cost' => '' === $settings['cost'] ? 0 : $settings['cost'], 'taxes' => $settings['tax_status'], 'total_pickup_locations' => count( $locations ), 'pickup_locations_enabled' => count( array_filter( $locations, function( $location ) { return $location['enabled']; } ) ), ); WC_Tracks::record_event( $event_name, $data ); return $served; } }
Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Blocks\Shipping\ShippingController' not found in /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Bootstrap.php:433 Stack trace: #0 /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\Blocks\Domain\Bootstrap->Automattic\WooCommerce\Blocks\Domain\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #1 /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #2 /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #3 /home/arasetne/publi in /home/arasetne/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Bootstrap.php on line 433