Automattic\WooCommerce\Blocks\BlockTypes

Cart::register_patterns()publicWC 1.0

Register block pattern for Empty Cart Message to make it translatable.

Method of the class: Cart{}

No Hooks.

Return

null. Nothing (null).

Usage

$Cart = new Cart();
$Cart->register_patterns();

Cart::register_patterns() code WC 9.7.1

public function register_patterns() {
	$shop_permalink = wc_get_page_id( 'shop' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : '';

	register_block_pattern(
		'woocommerce/cart-heading',
		array(
			'title'    => '',
			'inserter' => false,
			'content'  => '<!-- wp:heading {"align":"wide", "level":1} --><h1 class="wp-block-heading alignwide">' . esc_html__( 'Cart', 'woocommerce' ) . '</h1><!-- /wp:heading -->',
		)
	);
	register_block_pattern(
		'woocommerce/cart-cross-sells-message',
		array(
			'title'    => '',
			'inserter' => false,
			'content'  => '<!-- wp:heading {"fontSize":"large"} --><h2 class="wp-block-heading has-large-font-size">' . esc_html__( 'You may be interested in…', 'woocommerce' ) . '</h2><!-- /wp:heading -->',
		)
	);
	register_block_pattern(
		'woocommerce/cart-empty-message',
		array(
			'title'    => '',
			'inserter' => false,
			'content'  => '
				<!-- wp:heading {"textAlign":"center","className":"with-empty-cart-icon wc-block-cart__empty-cart__title"} --><h2 class="wp-block-heading has-text-align-center with-empty-cart-icon wc-block-cart__empty-cart__title">' . esc_html__( 'Your cart is currently empty!', 'woocommerce' ) . '</h2><!-- /wp:heading -->
				<!-- wp:paragraph {"align":"center"} --><p class="has-text-align-center"><a href="' . esc_attr( esc_url( $shop_permalink ) ) . '">' . esc_html__( 'Browse store', 'woocommerce' ) . '</a></p><!-- /wp:paragraph -->
			',
		)
	);
	register_block_pattern(
		'woocommerce/cart-new-in-store-message',
		array(
			'title'    => '',
			'inserter' => false,
			'content'  => '<!-- wp:heading {"textAlign":"center"} --><h2 class="wp-block-heading has-text-align-center">' . esc_html__( 'New in store', 'woocommerce' ) . '</h2><!-- /wp:heading -->',
		)
	);
}