Skip to content

Instantly share code, notes, and snippets.

@tongdaitructuyen
Created February 19, 2022 11:21
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 tongdaitructuyen/afb2af694bcafe884997c990b91f2d98 to your computer and use it in GitHub Desktop.
Save tongdaitructuyen/afb2af694bcafe884997c990b91f2d98 to your computer and use it in GitHub Desktop.
Cách thêm biểu tượng loại bỏ (xóa) sản phẩm trong trang thanh toán WooCommerce >>> https://www.mycomputer.vn/cach-them-bieu-tuong-loai-bo-xoa-san-pham-vao-trang-thanh-toan-woocommerce/
/**
* Add Remove button to WooCommerce checkout page - cart items
*/
add_filter('woocommerce_cart_item_name', 'mycomputer_filter_wc_cart_item_remove_link', 10, 3);
function mycomputer_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