Skip to content

Instantly share code, notes, and snippets.

@jamesckemp
Created May 6, 2021 13:37
Show Gist options
  • Save jamesckemp/baa74dadd2e6e1648d38e2cdaccc04d6 to your computer and use it in GitHub Desktop.
Save jamesckemp/baa74dadd2e6e1648d38e2cdaccc04d6 to your computer and use it in GitHub Desktop.
Change the variable product button text in WooCommerce
<?php
/**
* Change variable product text.
*
* [link to article]
*
* @param string $button_text
* @param WC_Product $product
*
* @return string|void
*/
function iconic_change_variable_product_button_text ( $button_text, $product ) {
if ( ! $product->is_type( 'variable' ) ) {
return $button_text;
}
return __( 'View Product', 'iconic' );
}
add_filter( 'woocommerce_product_add_to_cart_text', 'iconic_change_variable_product_button_text', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment