Change Button Link depending of site
-
Hi, for some reasons I want to change the links from “add to cart” buttons. So when on archive-product.php the link of this button should NOT got to the add-to-cart page but to the single-product page. (single-product.php)
When on single-product.php the button should link to another custom page I’ll define but also not to the add-to-cart page. (Which I don’t need for this use-case)
I realize, that this must be a conditional filter in functions.php –?but I have no clue of how to make this.
I managed to change the Button texts depending on the page I am. Like:
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); function woocommerce_custom_single_add_to_cart_text() { return __( 'Produkt verhindern', 'woocommerce' ); } // To change add to cart text on product archives(Collection) page add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' ); function woocommerce_custom_product_add_to_cart_text() { return __( 'Mehr erfahren', 'woocommerce' ); }
Thank you for your help and time,
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Change Button Link depending of site’ is closed to new replies.