Created
July 7, 2020 04:46
-
-
Save farookibrahim/3903458a002a14602e81d4c1adc4a914 to your computer and use it in GitHub Desktop.
WooCommerce - Custom "Add to cart" text
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
| function woocommerce_custom_product_add_to_cart_text( $text, $product ) { | |
| $product_type = $product->product_type; | |
| switch ( $product_type ) { | |
| case 'external': | |
| return __( 'Buy product', 'woocommerce' ); | |
| break; | |
| case 'grouped': | |
| return __( 'View products', 'woocommerce' ); | |
| break; | |
| case 'simple': | |
| return __( 'Add to cart', 'woocommerce' ); | |
| break; | |
| case 'variable': | |
| return __( 'Select options', 'woocommerce' ); | |
| break; | |
| default: | |
| return __( 'Read more', 'woocommerce' ); | |
| } | |
| } | |
| add_filter( 'woocommerce_product_add_to_cart_text' , 'woocommerce_custom_product_add_to_cart_text', 20, 2 ); | |
| function woocommerce_custom_product_single_add_to_cart_text( $text, $product ) { | |
| return __( 'Add to cart', 'woocommerce' ); | |
| } | |
| add_filter( 'woocommerce_product_single_add_to_cart_text' , 'woocommerce_custom_product_single_add_to_cart_text', 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment