diff --git a/src/BlockTypes/Cart.php b/src/BlockTypes/Cart.php index a5c942c1630..2286d984ef9 100644 --- a/src/BlockTypes/Cart.php +++ b/src/BlockTypes/Cart.php @@ -23,6 +23,52 @@ class Cart extends AbstractBlock { */ protected $chunks_folder = 'cart-blocks'; + /** + * 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_patterns' ) ); + } + + /** + * Register block pattern for Empty Cart Message to make it translatable. + */ + public function register_patterns() { + $shop_permalink = wc_get_page_id( 'shop' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : ''; + + register_block_pattern( + 'woocommerce/cart-cross-sells-message', + array( + 'title' => '', + 'inserter' => false, + 'content' => '

' . esc_html__( 'You may be interested in…', 'woo-gutenberg-products-block' ) . '

', + ) + ); + register_block_pattern( + 'woocommerce/cart-empty-message', + array( + 'title' => '', + 'inserter' => false, + 'content' => ' +

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

+

' . esc_html__( 'Browse store', 'woo-gutenberg-products-block' ) . '

+ ', + ) + ); + register_block_pattern( + 'woocommerce/cart-new-in-store-message', + array( + 'title' => '', + 'inserter' => false, + 'content' => '

' . esc_html__( 'New in store', 'woo-gutenberg-products-block' ) . '

', + ) + ); + } + /** * Get the editor script handle for this block type. * diff --git a/templates/templates/blockified/cart.html b/templates/templates/blockified/cart.html index ac2d783af1d..2d8014513a0 100644 --- a/templates/templates/blockified/cart.html +++ b/templates/templates/blockified/cart.html @@ -1,26 +1,31 @@
-
-
-
+
+ +
+ +
+
-
-

You may be interested in…

- - +
+
-
-
+ +
+ +
-
-
+
+ +
+
@@ -46,7 +51,8 @@

You may be interested in…

-
+ +
@@ -59,36 +65,44 @@

You may be interested in…

-
-
+ +
+ +
-
-
-
+
+ +
+ +
+
-
-

You may be interested in…

- - +
+
-
-
+ +
+ +
-
-
+
+ +
+
-
+
+
@@ -109,7 +123,8 @@

You may be interested in…

-
+ +
@@ -122,31 +137,28 @@

You may be interested in…

-
-
+ +
+ +
-
-

- Your cart is currently empty!

- - - -

Browse store

- +
+ -
+
- -

New in store

- - -
-
-
-
+ + +
+ +
+ +
+ + - + \ No newline at end of file diff --git a/templates/templates/cart.html b/templates/templates/cart.html index ac2d783af1d..2d8014513a0 100644 --- a/templates/templates/cart.html +++ b/templates/templates/cart.html @@ -1,26 +1,31 @@
-
-
-
+
+ +
+ +
+
-
-

You may be interested in…

- - +
+
-
-
+ +
+ +
-
-
+
+ +
+
@@ -46,7 +51,8 @@

You may be interested in…

-
+ +
@@ -59,36 +65,44 @@

You may be interested in…

-
-
+ +
+ +
-
-
-
+
+ +
+ +
+
-
-

You may be interested in…

- - +
+
-
-
+ +
+ +
-
-
+
+ +
+
-
+
+
@@ -109,7 +123,8 @@

You may be interested in…

-
+ +
@@ -122,31 +137,28 @@

You may be interested in…

-
-
+ +
+ +
-
-

- Your cart is currently empty!

- - - -

Browse store

- +
+ -
+
- -

New in store

- - -
-
-
-
+ + +
+ +
+ +
+ + - + \ No newline at end of file