Automattic\WooCommerce\Blocks

AssetsController::get_prerender_resource_hints()privateWC 1.0

Get resource hints during prerender requests.

Method of the class: AssetsController{}

No Hooks.

Return

Array. Array of URLs.

Usage

// private - for code of main (parent) class only
$result = $this->get_prerender_resource_hints();

AssetsController::get_prerender_resource_hints() code WC 9.0.1

private function get_prerender_resource_hints() {
	$urls          = array();
	$is_block_cart = has_block( 'woocommerce/cart' );

	if ( ! $is_block_cart ) {
		return $urls;
	}

	$checkout_page_id  = wc_get_page_id( 'checkout' );
	$checkout_page_url = $checkout_page_id ? get_permalink( $checkout_page_id ) : '';

	if ( $checkout_page_url ) {
		$urls[] = $checkout_page_url;
	}

	return $urls;
}