There is a WooCommerce Hook called woocommerce_cart_collaterals that displays a text in a div that I would like to change.
This is the short form of the unmodified HTML output:
<div >
<div >
<h2>You might be interested in...</h2>
...
</div>
</div>
I would like to change the text inside the h2. I have added an action for this hook but the given argument variable is just empty, I don't know what to do to get access to the h2.
This is what I've tried by adding to the theme's functions.php:
function action_woocommerce_cart_collaterals( $woocommerce_cart_totals) {
print_r($woocommerce_cart_totals);
};
add_action( 'woocommerce_cart_collaterals', 'action_woocommerce_cart_collaterals', 10, 1);
What to do I need to modify to edit the text output in the h2?
CodePudding user response:
The woocommerce_cart_collaterals
action hook callback function, contains no arguments. Use the woocommerce_product_cross_sells_products_heading
filter hook instead
So you get:
function filter_woocommerce_product_cross_sells_products_heading( $string ) {
// New text
$string = __( 'My new text', 'woocommerce' );
return $string;
}
add_filter( 'woocommerce_product_cross_sells_products_heading', 'filter_woocommerce_product_cross_sells_products_heading', 10, 1 );