Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Njengah/18854aa858d3384a7977bd25b35ac40b to your computer and use it in GitHub Desktop.
Save Njengah/18854aa858d3384a7977bd25b35ac40b to your computer and use it in GitHub Desktop.
Add Remove button to WooCommerce checkout page - cart items -https://njengah.com/how-to-add-remove-icon-to-woocommerce-checkout-page/
<?php
/**
* Add Remove button to WooCommerce checkout page - cart items
*/
add_filter('woocommerce_cart_item_name', 'njengah_filter_wc_cart_item_remove_link', 10, 3);
function njengah_filter_wc_cart_item_remove_link($product_name, $cart_item, $cart_item_key)
{
if (is_checkout()) {
$product_name .= apply_filters('woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" rel="nofollow" class="remove-icon" style="float:left;">x</a>',
esc_url(WC_Cart::get_remove_url($cart_item_key)),
__('Remove this item', 'woocommerce'),
esc_attr($cart_item['product_id']),
esc_attr($cart_item['data']->get_sku())
), $cart_item_key);
return $product_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment