I'm using this to change the add to cart text in woocommerce:
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' ); // 2.1 +
function woo_archive_custom_cart_button_text() {
return __( 'ADD TO CART', 'woocommerce' );
}
I would like to get_title(); instead of 'ADD TO CART' but I'm out in the dark.
You can get the product title inside hook via,
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' ); // 2.1 +
function woo_archive_custom_cart_button_text() {
global $product;
return __( $product->title , 'woocommerce' );
}
This worked:
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' ); // 2.1 +
function woo_archive_custom_cart_button_text() {
global $product;
return __( $product->get_title() , 'woocommerce' );
}
Now how to return both $product->get_price() and $product->get_title() -- I imagine through an array?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.