Commit d7d94c34521 for woocommerce
commit d7d94c345218e763136bc395f59a51bb0ba42287
Author: Thomas Roberts <5656702+opr@users.noreply.github.com>
Date: Wed Apr 1 09:35:43 2026 -0400
Replace 'Return to Cart' link with cart icon in checkout header (#63678)
* Replace 'Return to Cart' link with cart icon in checkout header
Add woocommerce/cart-link block to the checkout header template,
providing a cart icon as the navigation path back to cart. Change
showReturnToCart default to false to remove the text link from
the checkout action area near Place Order.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add aria-label to cart-link block when content is empty
When the cart-link block is rendered icon-only (empty content attribute),
screen readers had no accessible name for the link. Add an aria-label
fallback of "Cart" when the visible text is empty.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
diff --git a/plugins/woocommerce/changelog/opr-checkout-cart-icon b/plugins/woocommerce/changelog/opr-checkout-cart-icon
new file mode 100644
index 00000000000..bf90bf7c865
--- /dev/null
+++ b/plugins/woocommerce/changelog/opr-checkout-cart-icon
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Replace 'Return to Cart' link with a cart icon in the checkout header
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/context.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/context.ts
index f8ccef62e65..87ccca7ba23 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/context.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/context.ts
@@ -23,7 +23,7 @@ export type CheckoutBlockContextProps = {
const defaultCheckoutBlockContext = {
showOrderNotes: true,
showPolicyLinks: true,
- showReturnToCart: true,
+ showReturnToCart: false,
cartPageId: 0,
showRateAfterTaxName: false,
showFormStepNumbers: false,
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/block.json b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/block.json
index 8bd66a92ba2..2902b72cd6f 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/block.json
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/block.json
@@ -26,7 +26,7 @@
},
"showReturnToCart": {
"type": "boolean",
- "default": true
+ "default": false
},
"className": {
"type": "string",
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/CartLink.php b/plugins/woocommerce/src/Blocks/BlockTypes/CartLink.php
index 0321322975d..58ee3ac7ce9 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/CartLink.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/CartLink.php
@@ -29,9 +29,10 @@ class CartLink extends AbstractBlock {
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
$icon = MiniCartUtils::get_svg_icon( $attributes['cartIcon'] ?? '' );
$text = array_key_exists( 'content', $attributes ) ? esc_html( $attributes['content'] ) : esc_html__( 'Cart', 'woocommerce' );
+ $aria_label = empty( $text ) ? sprintf( ' aria-label="%s"', esc_attr__( 'Cart', 'woocommerce' ) ) : '';
return sprintf(
- '<div %1$s><a class="wc-block-cart-link" href="%2$s">%3$s<span class="wc-block-cart-link__text">%4$s</span></a></div>',
+ '<div %1$s><a class="wc-block-cart-link" href="%2$s"%5$s>%3$s<span class="wc-block-cart-link__text">%4$s</span></a></div>',
get_block_wrapper_attributes(
array(
'class' => esc_attr( $classes_and_styles['classes'] ),
@@ -40,7 +41,8 @@ class CartLink extends AbstractBlock {
),
esc_url( wc_get_cart_url() ),
$icon,
- $text
+ $text,
+ $aria_label
);
}
diff --git a/plugins/woocommerce/templates/parts/checkout-header.html b/plugins/woocommerce/templates/parts/checkout-header.html
index 41c3bf54081..aef8bddbd9a 100644
--- a/plugins/woocommerce/templates/parts/checkout-header.html
+++ b/plugins/woocommerce/templates/parts/checkout-header.html
@@ -3,6 +3,7 @@
<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"bottom":"var:preset|spacing|20","top":"var:preset|spacing|20"}}},"layout":{"type":"flex","justifyContent":"space-between"}} -->
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<!-- wp:site-title {"level":0} /-->
+ <!-- wp:woocommerce/cart-link {"content":""} /-->
</div>
<!-- /wp:group -->
</header>