Add an Icon to the Add to Cart Button

So, how do you add an icon (or an HTML symbol) to the add to cart buttons in WooCommerce? This can be done in two ways – via CSS if you want to show Fontawesome Icons or via PHP if you prefer to use a simple HTML unicode symbol.

add_filter( 'woocommerce_product_single_add_to_cart_text', 'codeithub_add_symbol_add_cart_button_single' );
 
function codeithub_add_symbol_add_cart_button_single( $button ) {
$button_new = '» ' . $button;
return $button_new;
}

Before:

Add to Cart Button

After:

Icon on Add to Cart

Leave a Reply

Your email address will not be published. Required fields are marked *