Last active
December 25, 2019 05:29
-
-
Save WPprodigy/11769a6104b663a2fe609321e00fdd0b to your computer and use it in GitHub Desktop.
Change add to cart url and text for simple products.
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
| add_filter( 'woocommerce_product_add_to_cart_url', 'wc_ninja_edit_add_to_cart_url', 10, 2 ); | |
| function wc_ninja_edit_add_to_cart_url( $url, $product ) { | |
| if ( 'simple' === $product->get_type() ) { | |
| $url = $product->get_permalink(); | |
| } | |
| return $url; | |
| } | |
| add_filter( 'woocommerce_product_add_to_cart_text', 'wc_ninja_edit_add_to_cart_text', 10, 2 ); | |
| function wc_ninja_edit_add_to_cart_text( $text, $product ) { | |
| if ( 'simple' === $product->get_type() ) { | |
| $text = __( 'Select options', 'woocommerce' ); | |
| } | |
| return $text; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will need to disable the "Enable AJAX add to cart buttons on archives" option at WooCommerce > Settings > Products > Display.