Created
June 8, 2014 21:44
-
-
Save claudiosanches/b3b437c16acd8e4987db to your computer and use it in GitHub Desktop.
WooCommerce - Change the product loop add to cart button text per product type
This file contains hidden or 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 | |
| function custom_woocommerce_product_add_to_cart_text( $text, $product ) { | |
| switch ( $product->product_type ) { | |
| case 'simple': | |
| return __( 'Texto para produto simples' ); | |
| break; | |
| case 'variable': | |
| return __( 'Texto para produto variável' ); | |
| break; | |
| case 'grouped': | |
| return __( 'Texto para grupo de produtos' ); | |
| break; | |
| default: | |
| return $text; | |
| break; | |
| } | |
| } | |
| add_filter( 'woocommerce_product_add_to_cart_text', 'custom_woocommerce_product_add_to_cart_text', 10, 2 ); | |
Não havia pensando em passar eles com um switch o que torna o código bem prático ao invés de esta fazendo isto:
add_filter('woocommerce_product_single_add_to_cart_text', 'wc_custom_cart_button_text', 10);
function wc_custom_cart_button_text(){
return __('Adicionar ao carrinho', 'woocommerce');
}
add_filter('woocoomerce_product_add_to_cart_text','wc_archive_custom_cart_button_text', 10);
function wc_archive_custom_cart_button_text(){
return __('Adicionar ao carrinho', 'woocommerce');
}
obrigado!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Achei seus Snippets!! Vou ter que te pagar uns cafés!! He he! Valew man!
Estão ajudando muito aqui ;)