Skip to content

Instantly share code, notes, and snippets.

@dleone81
Last active February 13, 2017 12:26
Show Gist options
  • Save dleone81/50d1a29e14acde30b378f3371d20df9e to your computer and use it in GitHub Desktop.
Save dleone81/50d1a29e14acde30b378f3371d20df9e to your computer and use it in GitHub Desktop.
Remove specific product from woo commerce cart
function remove_product_from_cart() {
if( is_cart() || is_checkout() ) {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item_key => $item){
if($item['line_total'] == '0' && $item['line_subtotal'] == '0') {
$remove_items = $woocommerce->cart->remove_cart_item($item_key);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment