Last active
September 7, 2020 10:56
-
-
Save Willem-Siebe/dc34719917e77fcecbc6 to your computer and use it in GitHub Desktop.
Replace the 'x' in WooCommerce cart.php with text because 'x' is not helpfull at all for screenreader users. I give a extra class to the text so that it can be hidden with CSS for visual browsers, because I replace that link with Font Awesome icon using :before. See also: https://github.com/woothemes/woocommerce/issues/5725.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace the 'x' in WooCommerce cart.php with text because 'x' is not helpfull at all for screenreader users, see https://gist.github.com/Willem-Siebe/dc34719917e77fcecbc6. | |
function wsis_woocommerce_remove_item( $wsis_html, $cart_item_key ) { | |
$cart_item_key = $cart_item_key; | |
$wsis_html = sprintf( '<a href="%s" class="remove" title="%s"><span class="wsis-remove-item">%s</span></a>', esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ), __( 'Remove this item', 'woocommerce' )); | |
return $wsis_html; | |
} | |
add_filter ( 'woocommerce_cart_item_remove_link', 'wsis_woocommerce_remove_item', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately This code will remove two data attributes in the output data-product_id and data-product_sku.
You can do it using the action [woocommerce_before_cart_contents] to get the cart list in a global variable once before foreach begins and of course the main filter [woocommerce_cart_item_remove_link].