Commit 1243ead1f39 for woocommerce
commit 1243ead1f39cc782100d2ff0f4eb3fa07050dd68
Author: Taha Paksu <3295+tpaksu@users.noreply.github.com>
Date: Mon Oct 12 13:35:33 2026 +0300
Fix missing review link in customer review request block email (#69575)
diff --git a/plugins/woocommerce/changelog/69575-wooplug-7904-customer-review-request-email-template-has-no-button-order b/plugins/woocommerce/changelog/69575-wooplug-7904-customer-review-request-email-template-has-no-button-order
new file mode 100644
index 00000000000..fadfc367b4f
--- /dev/null
+++ b/plugins/woocommerce/changelog/69575-wooplug-7904-customer-review-request-email-template-has-no-button-order
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Show the "Leave a review" link in the customer review request email when using the block email editor.
diff --git a/plugins/woocommerce/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProvider.php b/plugins/woocommerce/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProvider.php
index 0f4882860c8..5b59531d748 100644
--- a/plugins/woocommerce/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProvider.php
+++ b/plugins/woocommerce/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProvider.php
@@ -304,6 +304,23 @@ class OrderTagsProvider extends AbstractTagProvider {
)
);
+ $registry->register(
+ new Personalization_Tag(
+ __( 'Order Review URL', 'woocommerce' ),
+ 'woocommerce/order-review-url',
+ __( 'Order', 'woocommerce' ),
+ function ( array $context ): string {
+ if ( ! isset( $context['order'] ) ) {
+ return '';
+ }
+ return wc_get_review_order_url( $context['order'] );
+ },
+ array(),
+ null,
+ array( Integration::EMAIL_POST_TYPE ),
+ )
+ );
+
$registry->register(
new Personalization_Tag(
__( 'Order Custom Field', 'woocommerce' ),
diff --git a/plugins/woocommerce/templates/emails/block/customer-review-request.php b/plugins/woocommerce/templates/emails/block/customer-review-request.php
index af3bb245df8..7a630e2adb8 100644
--- a/plugins/woocommerce/templates/emails/block/customer-review-request.php
+++ b/plugins/woocommerce/templates/emails/block/customer-review-request.php
@@ -12,7 +12,7 @@
*
* @see https://woocommerce.com/document/template-structure/
* @package WooCommerce\Templates\Emails\Block
- * @version 10.8.0
+ * @version 11.3.0
*/
defined( 'ABSPATH' ) || exit;
@@ -36,6 +36,22 @@ defined( 'ABSPATH' ) || exit;
<p> <?php echo esc_html__( 'We’d love to know what you thought of the products you ordered. Your review helps other shoppers make better decisions and helps us improve.', 'woocommerce' ); ?> </p>
<!-- /wp:paragraph -->
+<!-- wp:paragraph -->
+<p><?php
+ $link_template = '<a data-link-href="%1$s" contenteditable="false" style="text-decoration: underline;">%2$s</a>';
+ printf(
+ '%s',
+ wp_kses_post(
+ sprintf(
+ $link_template,
+ esc_attr( '[woocommerce/order-review-url]' ),
+ esc_html__( 'Leave a review', 'woocommerce' )
+ )
+ )
+ );
+ ?></p>
+<!-- /wp:paragraph -->
+
<!-- wp:paragraph -->
<p><?php
/* translators: 1: order number, 2: order date */
diff --git a/plugins/woocommerce/tests/php/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProviderTest.php b/plugins/woocommerce/tests/php/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProviderTest.php
new file mode 100644
index 00000000000..8008d756b50
--- /dev/null
+++ b/plugins/woocommerce/tests/php/src/Internal/EmailEditor/PersonalizationTags/OrderTagsProviderTest.php
@@ -0,0 +1,73 @@
+<?php
+declare( strict_types = 1 );
+
+namespace Automattic\WooCommerce\Tests\Internal\EmailEditor\PersonalizationTags;
+
+use Automattic\WooCommerce\EmailEditor\Engine\Logger\Email_Editor_Logger;
+use Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags\Personalization_Tags_Registry;
+use Automattic\WooCommerce\Internal\EmailEditor\PersonalizationTags\OrderTagsProvider;
+use WC_Helper_Order;
+use WC_Unit_Test_Case;
+
+/**
+ * Tests for the OrderTagsProvider class.
+ */
+class OrderTagsProviderTest extends WC_Unit_Test_Case {
+
+ /**
+ * Registry with the order tags registered.
+ *
+ * @var Personalization_Tags_Registry
+ */
+ private $registry;
+
+ /**
+ * Set up test fixtures.
+ */
+ public function setUp(): void {
+ parent::setUp();
+ $this->registry = new Personalization_Tags_Registry( new Email_Editor_Logger() );
+ ( new OrderTagsProvider() )->register_tags( $this->registry );
+ }
+
+ /**
+ * @testdox Registers the order review URL tag.
+ */
+ public function test_registers_order_review_url_tag(): void {
+ $tag = $this->registry->get_by_token( '[woocommerce/order-review-url]' );
+
+ $this->assertNotNull( $tag, 'The order review URL tag should be registered.' );
+ $this->assertSame( __( 'Order', 'woocommerce' ), $tag->get_category() );
+ }
+
+ /**
+ * @testdox The order review URL tag resolves to the order's review URL.
+ */
+ public function test_order_review_url_tag_resolves_to_review_url(): void {
+ $order = WC_Helper_Order::create_order();
+
+ // The review-order page is not seeded in the test environment, so pin the
+ // URL through the public filter to prove the tag delegates to it per order.
+ $expected = 'https://example.test/review-order/' . $order->get_id() . '/?key=' . $order->get_order_key();
+ $filter = function ( $url, $filter_order ) use ( $order, $expected ) {
+ unset( $url );
+ return $filter_order->get_id() === $order->get_id() ? $expected : '';
+ };
+ add_filter( 'woocommerce_review_order_url', $filter, 10, 2 );
+
+ $url = $this->registry->get_by_token( '[woocommerce/order-review-url]' )->execute_callback( array( 'order' => $order ) );
+
+ remove_filter( 'woocommerce_review_order_url', $filter, 10 );
+
+ $this->assertSame( $expected, $url );
+ }
+
+ /**
+ * @testdox The order review URL tag returns an empty string without order context.
+ */
+ public function test_order_review_url_tag_without_order_context(): void {
+ $tag = $this->registry->get_by_token( '[woocommerce/order-review-url]' );
+
+ $this->assertSame( '', $tag->execute_callback( array() ) );
+ }
+}