Robert Granlund
asked on
Wordpress Override Core Functions
There is a Core Function within the Woo Commerce Plugin. I would like to create a custom function, in my functions.php file that overrides the Woo Commerce Core function.
I'm not sure how.
The Woo Commerce Function is this:
The custom Function I would like to use is the following.
I'm not sure how.
The Woo Commerce Function is this:
public function single_add_to_cart_text() {
return apply_filters( 'woocommerce_product_single_add_to_cart_text', __( 'Add to cart', 'woocommerce' ), $this );
}
The custom Function I would like to use is the following.
<?php
if ( is_home() ) {
public function single_add_to_cart_text() {
return apply_filters( 'woocommerce_product_single_add_to_cart_text', __( 'Add to Backpack', 'woocommerce' ), $this );
}
} else {
public function single_add_to_cart_text() {
return apply_filters( 'woocommerce_product_single_add_to_cart_text', __( 'Add to cart', 'woocommerce' ), $this );
}
}
?>
How do I make that work? You can see that all I want to do is change the text if it is the home page. The documentation said to not mess with the woo commerce core files but override in my functions file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@eemit That seems like it should work, but does not. In the child functions.php does it know the it is the home page? Meaning is it starting to early in the code for it to know?
Try is_front_page() instead of is_home().
ASKER
@eemit, thank you for your help I realized I gave you the wrong initial function name. My bad. It works 100% now. Thanks!!!
ASKER
Open in new window