Automattic\WooCommerce\Blocks\Shipping

ShippingController::init()publicWC 1.0

Initialization method.

Method of the class: ShippingController{}

No Hooks.

Return

null. Nothing (null).

Usage

$ShippingController = new ShippingController();
$ShippingController->init();

ShippingController::init() code WC 9.2.3

public function init() {
	if ( is_admin() ) {
		$this->asset_data_registry->add(
			'countryStates',
			function () {
				return WC()->countries->get_states();
			}
		);
	}

	$this->asset_data_registry->add( 'collectableMethodIds', array( 'Automattic\WooCommerce\StoreApi\Utilities\LocalPickupUtils', 'get_local_pickup_method_ids' ) );
	$this->asset_data_registry->add( 'shippingCostRequiresAddress', get_option( 'woocommerce_shipping_cost_requires_address', false ) === 'yes' );
	add_action( 'rest_api_init', array( $this, 'register_settings' ) );
	add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
	add_action( 'admin_enqueue_scripts', array( $this, 'hydrate_client_settings' ) );
	add_action( 'woocommerce_load_shipping_methods', array( $this, 'register_local_pickup' ) );
	add_filter( 'woocommerce_local_pickup_methods', array( $this, 'register_local_pickup_method' ) );
	add_filter( 'woocommerce_order_hide_shipping_address', array( $this, 'hide_shipping_address_for_local_pickup' ), 10 );
	add_filter( 'woocommerce_customer_taxable_address', array( $this, 'filter_taxable_address' ) );
	add_filter( 'woocommerce_shipping_packages', array( $this, 'filter_shipping_packages' ) );
	add_filter( 'pre_update_option_woocommerce_pickup_location_settings', array( $this, 'flush_cache' ) );
	add_filter( 'pre_update_option_pickup_location_pickup_locations', array( $this, 'flush_cache' ) );
	add_filter( 'woocommerce_shipping_settings', array( $this, 'remove_shipping_settings' ) );
	add_filter( 'woocommerce_order_shipping_to_display', array( $this, 'show_local_pickup_details' ), 10, 2 );

	// This is required to short circuit `show_shipping` from class-wc-cart.php - without it, that function
	// returns based on the option's value in the DB and we can't override it any other way.
	add_filter( 'option_woocommerce_shipping_cost_requires_address', array( $this, 'override_cost_requires_address_option' ) );

	add_action( 'rest_pre_serve_request', array( $this, 'track_local_pickup' ), 10, 4 );
}