Skip to content

Instantly share code, notes, and snippets.

@bekarice
Last active February 4, 2019 23:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bekarice/4252644607751b0560c2 to your computer and use it in GitHub Desktop.
Save bekarice/4252644607751b0560c2 to your computer and use it in GitHub Desktop.
Change WooCommerce Product Retailers button text
/**
* Add as many cases as needed; this will change all button labels for a retailer
* NOTE: this will only work if the product has >1 retailer (multiple buttons)
**/
function skyverge_change_retailer_button_labels( $label, $retailer, $product ) {
switch ( $retailer->get_name() ) {
case 'Amazon':
$label = 'Buy Paperback at Amazon';
break;
case 'Kindle':
$label = 'Buy Kindle Edition';
break;
case 'iBooks':
$label = 'Buy iBook';
break;
default:
return $label;
}
return $label . ' - $' . $retailer->get_price();
// Use your currency symbol intead of $ if different from US dollars
}
add_filter( 'wc_product_retailers_button_label', 'skyverge_change_retailer_button_labels', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment