From e9d8cb3beed0f04920f8040eb8d207a95938eaa2 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 19 Jul 2023 19:01:05 +0200 Subject: [PATCH 1/5] Add missing page titles to the Cart and Checkout templates --- templates/templates/cart.html | 10 +++++++--- templates/templates/checkout.html | 10 ++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/templates/templates/cart.html b/templates/templates/cart.html index 2d8014513a0..0698872ab46 100644 --- a/templates/templates/cart.html +++ b/templates/templates/cart.html @@ -1,14 +1,18 @@ -
+
+ +

Cart

+ + +
-
- +
diff --git a/templates/templates/checkout.html b/templates/templates/checkout.html index 69b87260048..a58c9f75e79 100644 --- a/templates/templates/checkout.html +++ b/templates/templates/checkout.html @@ -1,7 +1,13 @@ -
-
+
+ +

Checkout

+ + + +
+
From 9fa9c0c21efdf5dc38c737b317dd1cba28e21858 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 19 Jul 2023 19:03:07 +0200 Subject: [PATCH 2/5] Adjust headline level --- templates/templates/cart.html | 5 +++-- templates/templates/checkout.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/templates/cart.html b/templates/templates/cart.html index 0698872ab46..0e35404cc7d 100644 --- a/templates/templates/cart.html +++ b/templates/templates/cart.html @@ -2,7 +2,7 @@
-

Cart

+

Cart

@@ -12,7 +12,8 @@

Cart

-
+
+
diff --git a/templates/templates/checkout.html b/templates/templates/checkout.html index a58c9f75e79..aad108dfac8 100644 --- a/templates/templates/checkout.html +++ b/templates/templates/checkout.html @@ -2,7 +2,7 @@
-

Checkout

+

Checkout

From 607ad682ed3616d7c8b19babee262327fce9918b Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Thu, 20 Jul 2023 12:05:20 +0200 Subject: [PATCH 3/5] Add i18n support for Cart and Checkout template titles --- src/BlockTypes/Cart.php | 8 ++++++ src/BlockTypes/Checkout.php | 25 +++++++++++++++++++ templates/templates/blockified/cart.html | 7 ++++-- templates/templates/blockified/checkout.html | 26 ++++++++++++++------ templates/templates/cart.html | 6 ++--- templates/templates/checkout.html | 22 ++++++++++------- 6 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/BlockTypes/Cart.php b/src/BlockTypes/Cart.php index 79068f52071..4c25f14e46f 100644 --- a/src/BlockTypes/Cart.php +++ b/src/BlockTypes/Cart.php @@ -40,6 +40,14 @@ protected function initialize() { 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' => '

' . esc_html__( 'Cart', 'woo-gutenberg-products-block' ) . '

', + ) + ); register_block_pattern( 'woocommerce/cart-cross-sells-message', array( diff --git a/src/BlockTypes/Checkout.php b/src/BlockTypes/Checkout.php index c2019574b69..3db15254fcb 100644 --- a/src/BlockTypes/Checkout.php +++ b/src/BlockTypes/Checkout.php @@ -24,6 +24,31 @@ class Checkout extends AbstractBlock { */ protected $chunks_folder = 'checkout-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() { + register_block_pattern( + 'woocommerce/checkout-heading', + array( + 'title' => '', + 'inserter' => false, + 'content' => '

' . esc_html__( 'Checkout', '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 2d8014513a0..161f5add1f6 100644 --- a/templates/templates/blockified/cart.html +++ b/templates/templates/blockified/cart.html @@ -1,6 +1,9 @@ -
+
+ + +
@@ -161,4 +164,4 @@
- \ No newline at end of file + diff --git a/templates/templates/blockified/checkout.html b/templates/templates/blockified/checkout.html index 69b87260048..13450542f79 100644 --- a/templates/templates/blockified/checkout.html +++ b/templates/templates/blockified/checkout.html @@ -1,7 +1,11 @@ -
-
+
+ + + +
+
@@ -44,12 +48,14 @@
-
+ +
-
+
+
@@ -75,8 +81,12 @@
-
-
-
-
+ +
+ +
+ +
+ +
diff --git a/templates/templates/cart.html b/templates/templates/cart.html index 0e35404cc7d..161f5add1f6 100644 --- a/templates/templates/cart.html +++ b/templates/templates/cart.html @@ -1,9 +1,7 @@
- -

Cart

- +
@@ -166,4 +164,4 @@

Cart

- \ No newline at end of file + diff --git a/templates/templates/checkout.html b/templates/templates/checkout.html index aad108dfac8..13450542f79 100644 --- a/templates/templates/checkout.html +++ b/templates/templates/checkout.html @@ -1,9 +1,7 @@
- -

Checkout

- +
@@ -50,12 +48,14 @@

Checkout

-
+ +
-
+
+
@@ -81,8 +81,12 @@

Checkout

-
-
-
-
+ +
+ +
+ +
+ +
From 9acb40eb0e1162623947051c8308a99b9c2a7146 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Thu, 20 Jul 2023 13:26:49 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Keep=20empty=20line=20between=20=E2=80=9Cwp?= =?UTF-8?q?:group=E2=80=9D=20and=20=E2=80=9Cwp:template-part=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/templates/blockified/cart.html | 2 ++ templates/templates/cart.html | 2 ++ 2 files changed, 4 insertions(+) diff --git a/templates/templates/blockified/cart.html b/templates/templates/blockified/cart.html index 161f5add1f6..d7c38281d86 100644 --- a/templates/templates/blockified/cart.html +++ b/templates/templates/blockified/cart.html @@ -1,4 +1,5 @@ +
@@ -164,4 +165,5 @@
+ diff --git a/templates/templates/cart.html b/templates/templates/cart.html index 161f5add1f6..d7c38281d86 100644 --- a/templates/templates/cart.html +++ b/templates/templates/cart.html @@ -1,4 +1,5 @@ +
@@ -164,4 +165,5 @@
+ From 71cab56d116e9ea540886e7f586eafea7037bf24 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Thu, 20 Jul 2023 13:27:05 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Add=20empty=20line=20between=20=E2=80=9Cwp:?= =?UTF-8?q?template-part=E2=80=9D=20and=20=E2=80=9Cwp:group=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/templates/blockified/checkout.html | 1 + templates/templates/checkout.html | 1 + 2 files changed, 2 insertions(+) diff --git a/templates/templates/blockified/checkout.html b/templates/templates/blockified/checkout.html index 13450542f79..476e9e7f1ef 100644 --- a/templates/templates/blockified/checkout.html +++ b/templates/templates/blockified/checkout.html @@ -1,4 +1,5 @@ +
diff --git a/templates/templates/checkout.html b/templates/templates/checkout.html index 13450542f79..476e9e7f1ef 100644 --- a/templates/templates/checkout.html +++ b/templates/templates/checkout.html @@ -1,4 +1,5 @@ +