WordPress как на ладони
Очень Удобный и Быстрый Хостинг для сайтов на WordPress. Рекомендую всем своим клиентам!
функция не описана

Automattic\WooCommerce\Blocks\BlockTypes

CheckoutI2::enqueue_data() protected WC 1.0

Extra data passed through from server to client for block.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

{} Это метод класса: CheckoutI2{}

Хуки из метода

Возвращает

null. Ничего.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->enqueue_data( $attributes );
$attributes(массив)
Any attributes that currently are available from the block. Note, this will be empty in the editor context when the block is not in the post content on editor load.
По умолчанию: []

Код CheckoutI2::enqueue_data() WC 5.8.0

protected function enqueue_data( array $attributes = [] ) {
	parent::enqueue_data( $attributes );

	$this->asset_data_registry->add(
		'allowedCountries',
		function() {
			return $this->deep_sort_with_accents( WC()->countries->get_allowed_countries() );
		},
		true
	);
	$this->asset_data_registry->add(
		'allowedStates',
		function() {
			return $this->deep_sort_with_accents( WC()->countries->get_allowed_country_states() );
		},
		true
	);
	$this->asset_data_registry->add(
		'shippingCountries',
		function() {
			return $this->deep_sort_with_accents( WC()->countries->get_shipping_countries() );
		},
		true
	);
	$this->asset_data_registry->add(
		'shippingStates',
		function() {
			return $this->deep_sort_with_accents( WC()->countries->get_shipping_country_states() );
		},
		true
	);
	$this->asset_data_registry->add(
		'countryLocale',
		function() {
			// Merge country and state data to work around https://github.com/woocommerce/woocommerce/issues/28944.
			$country_locale = wc()->countries->get_country_locale();
			$states         = wc()->countries->get_states();

			foreach ( $states as $country => $states ) {
				if ( empty( $states ) ) {
					$country_locale[ $country ]['state']['required'] = false;
					$country_locale[ $country ]['state']['hidden']   = true;
				}
			}
			return $country_locale;
		},
		true
	);
	$this->asset_data_registry->add( 'baseLocation', wc_get_base_location(), true );
	$this->asset_data_registry->add(
		'checkoutAllowsGuest',
		false === filter_var(
			WC()->checkout()->is_registration_required(),
			FILTER_VALIDATE_BOOLEAN
		),
		true
	);
	$this->asset_data_registry->add(
		'checkoutAllowsSignup',
		filter_var(
			WC()->checkout()->is_registration_enabled(),
			FILTER_VALIDATE_BOOLEAN
		),
		true
	);
	$this->asset_data_registry->add( 'checkoutShowLoginReminder', filter_var( get_option( 'woocommerce_enable_checkout_login_reminder' ), FILTER_VALIDATE_BOOLEAN ), true );
	$this->asset_data_registry->add( 'displayCartPricesIncludingTax', 'incl' === get_option( 'woocommerce_tax_display_cart' ), true );
	$this->asset_data_registry->add( 'displayItemizedTaxes', 'itemized' === get_option( 'woocommerce_tax_total_display' ), true );
	$this->asset_data_registry->add( 'taxesEnabled', wc_tax_enabled(), true );
	$this->asset_data_registry->add( 'couponsEnabled', wc_coupons_enabled(), true );
	$this->asset_data_registry->add( 'shippingEnabled', wc_shipping_enabled(), true );
	$this->asset_data_registry->add( 'hasDarkEditorStyleSupport', current_theme_supports( 'dark-editor-style' ), true );
	$this->asset_data_registry->register_page_id( isset( $attributes['cartPageId'] ) ? $attributes['cartPageId'] : 0 );

	$is_block_editor = $this->is_block_editor();

	// Hydrate the following data depending on admin or frontend context.
	if ( $is_block_editor && ! $this->asset_data_registry->exists( 'shippingMethodsExist' ) ) {
		$methods_exist = wc_get_shipping_method_count( false, true ) > 0;
		$this->asset_data_registry->add( 'shippingMethodsExist', $methods_exist );
	}

	if ( $is_block_editor && ! $this->asset_data_registry->exists( 'globalShippingMethods' ) ) {
		$shipping_methods           = WC()->shipping()->get_shipping_methods();
		$formatted_shipping_methods = array_reduce(
			$shipping_methods,
			function( $acc, $method ) {
				if ( $method->supports( 'settings' ) ) {
					$acc[] = [
						'id'          => $method->id,
						'title'       => $method->method_title,
						'description' => $method->method_description,
					];
				}
				return $acc;
			},
			[]
		);
		$this->asset_data_registry->add( 'globalShippingMethods', $formatted_shipping_methods );
	}

	if ( $is_block_editor && ! $this->asset_data_registry->exists( 'activeShippingZones' ) && class_exists( '\WC_Shipping_Zones' ) ) {
		$shipping_zones             = \WC_Shipping_Zones::get_zones();
		$formatted_shipping_zones   = array_reduce(
			$shipping_zones,
			function( $acc, $zone ) {
				$acc[] = [
					'id'          => $zone['id'],
					'title'       => $zone['zone_name'],
					'description' => $zone['formatted_zone_location'],
				];
				return $acc;
			},
			[]
		);
		$formatted_shipping_zones[] = [
			'id'          => 0,
			'title'       => __( 'International', 'woocommerce' ),
			'description' => __( 'Locations outside all other zones', 'woocommerce' ),
		];
		$this->asset_data_registry->add( 'activeShippingZones', $formatted_shipping_zones );
	}

	if ( $is_block_editor && ! $this->asset_data_registry->exists( 'globalPaymentMethods' ) ) {
		$payment_methods           = WC()->payment_gateways->payment_gateways();
		$formatted_payment_methods = array_reduce(
			$payment_methods,
			function( $acc, $method ) {
				if ( 'yes' === $method->enabled ) {
					$acc[] = [
						'id'          => $method->id,
						'title'       => $method->method_title,
						'description' => $method->method_description,
					];
				}
				return $acc;
			},
			[]
		);
		$this->asset_data_registry->add( 'globalPaymentMethods', $formatted_payment_methods );
	}

	if ( ! is_admin() && ! WC()->is_rest_api_request() ) {
		$this->hydrate_from_api();
		$this->hydrate_customer_payment_methods();
	}

	do_action( 'woocommerce_blocks_checkout_enqueue_data' );
}