miguel.nz

Replacing the remove product link and string on Woocommerce Cart

April 19, 2020   |   1 minute read.

The Woocommerce cart by default displays an ‘x’ as a “remove a product” option. You can replace and customise this by using the filter “woocommerce_cart_item_remove_link”. The following example guides you on how to display a custom message:

function woocommerce_remove_item( $html, $cart_item_key ) {
	$cart_item_key = $cart_item_key;
	$html = sprintf( '%s', 
		esc_url( wc_get_cart_remove_url( $cart_item_key ) ), 
		__( 'Remove', 'woocommerce' ), 
		__( 'Remove', 'woocommerce' ));
	return $html;
}

add_filter ( 'woocommerce_cart_item_remove_link', 'woocommerce_remove_item', 10, 2 );