Aleš Sýkora / November 28, 2023 / 0 comments

Change WooCommerce clear variations text

Post summary: If you’re looking to customize the text of the “Reset Variations” link in WooCommerce, you’ve come to the right place. In this article, we’ll walk you through the process of changing the reset variations text using a simple code snippet. What is reset variations text and where is located? It’s the text, which appears after…

If you’re looking to customize the text of the “Reset Variations” link in WooCommerce, you’ve come to the right place. In this article, we’ll walk you through the process of changing the reset variations text using a simple code snippet.

What is reset variations text and where is located?

It’s the text, which appears after you select your variation/s.

Change Woo reset variations text with code

The code snippet below is a filter that hooks into the woocommerce_reset_variations_link hook. This filter is responsible for modifying the HTML output of the “Reset Variations” link. The function gt_reset_variations_text is then defined to return a custom link structure with the desired text. You can place it in functions.php or in custom code snippets plugin.

add_filter('woocommerce_reset_variations_link','gt_reset_variations_text');
function gt_reset_variations_text()
{
	return '<a class="reset_variations" href="#">Put text here</a>'; //change the text here
}
  1. add_filter('woocommerce_reset_variations_link','gt_reset_variations_text');: This line adds a filter to the woocommerce_reset_variations_link hook, indicating that the gt_reset_variations_text function should be called when this filter is applied.
  2. function gt_reset_variations_text() { ... }: This function returns a custom HTML structure for the “Reset Variations” link. The text you want to customize is inside the <a> tag, where it says “Put text here.” You can replace this text with your desired variation reset text.

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

0 comments

Share Your Thoughts