diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 24b57a20881..91c222f8f7c 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -53,7 +53,17 @@ class MiniCart extends AbstractBlock { */ public function __construct( AssetApi $asset_api, AssetDataRegistry $asset_data_registry, IntegrationRegistry $integration_registry ) { parent::__construct( $asset_api, $asset_data_registry, $integration_registry, $this->block_name ); + } + /** + * Initialize this block type. + * + * - Hook into WP lifecycle. + * - Register the block with WordPress. + */ + protected function initialize() { + parent::initialize(); + add_action( 'wp_loaded', array( $this, 'register_empty_cart_message_block_pattern' ) ); } /** @@ -486,4 +496,18 @@ protected function get_inner_blocks_translations() { return implode( '', $translations ); } + + /** + * Register block pattern for Empty Cart Message to make it translatable. + */ + public function register_empty_cart_message_block_pattern() { + register_block_pattern( + 'woocommerce/mini-cart-empty-cart-message', + array( + 'title' => __( 'Mini Cart Empty Cart Message', 'woo-gutenberg-products-block' ), + 'inserter' => false, + 'content' => '

' . __( 'Your cart is currently empty!', 'woo-gutenberg-products-block' ) . '

', + ) + ); + } } diff --git a/templates/parts/mini-cart.html b/templates/parts/mini-cart.html index d053a8a72bf..ce618459183 100644 --- a/templates/parts/mini-cart.html +++ b/templates/parts/mini-cart.html @@ -23,11 +23,7 @@
- -

- Your cart is currently empty! -

- +