Automattic\WooCommerce\Blocks\Shipping
ShippingController::filter_taxable_address()
Filter the location used for taxes based on the chosen pickup location.
Метод класса: ShippingController{}
Хуки из метода
Возвращает
Массив
.
Использование
$ShippingController = new ShippingController(); $ShippingController->filter_taxable_address( $address );
- $address(массив) (обязательный)
- Location args.
Код ShippingController::filter_taxable_address() ShippingController::filter taxable address WC 9.2.3
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', array() ); $pickup_location = $pickup_locations[ $chosen_method_instance ] ?? array(); 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; }