M
M
MisTFoR2020-08-13 20:31:47
WooCommerce
MisTFoR, 2020-08-13 20:31:47

How to display html code in given php code?

Hello!
There is this code:

add_filter( 'woocommerce_product_single_add_to_cart_text', 'tb_woo_custom_cart_button_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'tb_woo_custom_cart_button_text' );   
function tb_woo_custom_cart_button_text() {
        return __( '+', 'woocommerce' );
}

It is in the catalog, in the product blocks, it replaces the text with a plus. I want to try to insert a picture, but if you write
add_filter( 'woocommerce_product_single_add_to_cart_text', 'tb_woo_custom_cart_button_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'tb_woo_custom_cart_button_text' );   
function tb_woo_custom_cart_button_text() {
        return __( '<img src="blabla">', 'woocommerce' );
}

Then it displays the text itself " <img src="blabla">", and not a picture, what should I do?

Thanks everyone for the replies

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Litvinenko, 2020-08-13
@MisTFoR

Redefine the button output template or insert a background through a pseudo-element. Filters personally did not work for me and Google did not help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question