Created
September 19, 2016 08:49
-
-
Save frankschrijvers/0332902abe4ca23edd595ceacee7b405 to your computer and use it in GitHub Desktop.
Change add to cart button text per category archive pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Change add to cart button text per category archive pages | |
add_filter( 'woocommerce_product_add_to_cart_text', 'wps_archive_custom_cart_button_text' ); | |
function wps_archive_custom_cart_button_text() { | |
global $product; | |
$terms = get_the_terms( $product->ID, 'product_cat' ); | |
foreach ($terms as $term) { | |
$product_cat = $term->slug; | |
break; | |
} | |
switch($product_cat) { | |
case 'clothing'; | |
return __('Order your Clothes', 'your_theme_text_domain' ); | |
default; | |
return __( 'Order now', 'your_theme_text_domain' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment