Automattic\WooCommerce\Blocks\Templates

SingleProductTemplate::render_block_templatepublicWC 1.0

Run template-specific logic when the query matches this template.

Метод класса: SingleProductTemplate{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$SingleProductTemplate = new SingleProductTemplate();
$SingleProductTemplate->render_block_template();

Код SingleProductTemplate::render_block_template() WC 11.0.1

public function render_block_template() {
	if ( ! is_embed() && is_singular( 'product' ) ) {
		global $post;

		$compatibility_layer = new SingleProductTemplateCompatibility();
		$compatibility_layer->init();

		$product = wc_get_product( $post->ID );
		if ( $product ) {
			$consent = 'I acknowledge that using experimental APIs means my theme or plugin will inevitably break in the next version of WooCommerce';

			// Load the product data into the products store so derived
			// state closures can resolve it during server-side rendering.
			ProductsStore::load_product( $consent, $product->get_id() );

			// Set the current product context. The derived state
			// closures (mainProductInContext, productVariationInContext, productInContext)
			// are registered by ProductsStore::register_state().
			wp_interactivity_state(
				'woocommerce/products',
				array(
					'productId'   => $product->get_id(),
					'variationId' => null,
				)
			);
		}
	}
}