Aurangajeb

Allows removing products on checkout page

Jun 9th, 2022
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. ##################################
  2. //Allows removing products on checkout page
  3. ##################################
  4.  
  5. function lionplugins_woocommerce_checkout_remove_item( $product_name, $cart_item, $cart_item_key ) {
  6.     if ( is_checkout() ) {
  7.         $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  8.         $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  9.  
  10.         $remove_link = apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
  11.             '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">Γ—</a>',
  12.             esc_url( WC()->cart->get_remove_url( $cart_item_key ) ),
  13.             __( 'Remove this item', 'woocommerce' ),
  14.             esc_attr( $product_id ),
  15.             esc_attr( $_product->get_sku() )
  16.         ), $cart_item_key );
  17.  
  18.         return '<span>' . $remove_link . '</span> <span>' . $product_name . '</span>';
  19.     }
  20.  
  21.     return $product_name;
  22. }
  23. add_filter( 'woocommerce_cart_item_name', 'lionplugins_woocommerce_checkout_remove_item', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment