Skip to content

Instantly share code, notes, and snippets.

@cpaul007
Created April 11, 2021 13:28
Show Gist options
  • Save cpaul007/c2d537b224d5e4af8cb8bdc5da441815 to your computer and use it in GitHub Desktop.
Save cpaul007/c2d537b224d5e4af8cb8bdc5da441815 to your computer and use it in GitHub Desktop.
How to add custom remove icon in Menu/Ultimate Cart
<?php //* Don't add this line
add_action( 'woocommerce_before_mini_cart_contents', 'ouwoo_custom_remove_icon', 11 );
function ouwoo_custom_remove_icon() {
remove_filter( 'woocommerce_cart_item_remove_link', 'ouwoo_woo_cart_remove_button', 10, 2 );
add_filter( 'woocommerce_cart_item_remove_link', 'ouwoo_add_custom_remove_button_icon', 10, 2 );
}
function ouwoo_add_custom_remove_button_icon($remove_link, $cart_item_key ) {
$svgFile = 'ADD YOUR SVG HTML CODE OR IMG HTML CODE HERE';
$remove_link = str_replace( '&times;', $svgFile, $remove_link );
return $remove_link;
}
add_action( 'woocommerce_after_mini_cart', function() {
remove_filter( 'woocommerce_cart_item_remove_link', 'ouwoo_add_custom_remove_button_icon', 10, 2 );
}, 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment