Commit 1cecb99e6ed for woocommerce
commit 1cecb99e6ed75b51a614e600b4c5b519623ba1f3
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date: Fri Apr 3 14:46:52 2026 +0200
Add to Cart Button: open external products link in a new tab (#63970)
* Add to Cart + Options: open external products link in a new tab
* Add changelog
* Only open in new tab in external products
* Add 'noopener noreferrer' to link's rel attribute
diff --git a/plugins/woocommerce/changelog/2026-04-01-13-16-19-880401 b/plugins/woocommerce/changelog/2026-04-01-13-16-19-880401
new file mode 100644
index 00000000000..9cf9f536304
--- /dev/null
+++ b/plugins/woocommerce/changelog/2026-04-01-13-16-19-880401
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+Add to Cart Button: open external products link in a new tab
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
index 11692fd9300..5d056036a2b 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
@@ -169,6 +169,11 @@ class ProductButton extends AbstractBlock {
'href' => esc_url( $product->add_to_cart_url() ),
'rel' => 'nofollow',
);
+
+ if ( $product->is_type( ProductType::EXTERNAL ) ) {
+ $attributes['target'] = '_blank';
+ $attributes['rel'] = 'nofollow noopener noreferrer';
+ }
}
wp_interactivity_config(