Add remove products button in checkout page WooCommerce

By following this tutorial we can add a remove button for products during checkout. just put that code in function.php of your wordpress theme:-

function woocommerce_checkout_remove_item($product_name, $cart_item, $cart_item_key) {
    if (is_checkout()) {
        $product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
        $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);

        $remove_link = apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
            '×',
            esc_url( WC()->cart->get_remove_url( $cart_item_key ) ),
            __( 'Remove this item', 'woocommerce' ),
            esc_attr( $product_id ),
            esc_attr( $product->get_sku() )
        ), $cart_item_key );

        return '' . $remove_link . ' ' . $product_name . '';
    }

    return $product_name;
}
add_filter('woocommerce_cart_item_name', 'woocommerce_checkout_remove_item', 10, 3);

Leave a Reply

Your email address will not be published. Required fields are marked *

The link has been Copied to clipboard!