remove products in checkout page woocommerce

Solutions on MaxInterview for remove products in checkout page woocommerce by the best coders in the world

showing results for - "remove products in checkout page woocommerce"
Karina
22 Jan 2021
1/**
2 * Allows to remove products in checkout page.
3 * 
4 * @param string $product_name 
5 * @param array $cart_item 
6 * @param string $cart_item_key 
7 * @return string
8 */
9function lionplugins_woocommerce_checkout_remove_item( $product_name, $cart_item, $cart_item_key ) {
10	if ( is_checkout() ) {
11		$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
12		$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
13
14		$remove_link = apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
15			'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">×</a>',
16			esc_url( WC()->cart->get_remove_url( $cart_item_key ) ),
17			__( 'Remove this item', 'woocommerce' ),
18			esc_attr( $product_id ),
19			esc_attr( $_product->get_sku() )
20        ), $cart_item_key );
21
22		return '<span>' . $remove_link . '</span> <span>' . $product_name . '</span>';
23	}
24
25	return $product_name;
26}
27add_filter( 'woocommerce_cart_item_name', 'lionplugins_woocommerce_checkout_remove_item', 10, 3 );