Skip to content

Instantly share code, notes, and snippets.

@alewolf
Created July 21, 2021 12:44
Show Gist options
  • Save alewolf/60732f27c44969cf6d93a8177434bcfd to your computer and use it in GitHub Desktop.
Save alewolf/60732f27c44969cf6d93a8177434bcfd to your computer and use it in GitHub Desktop.
remve an order item if it's value has been discounted to 0
<?php
// The product ID must be changed and must match the specific product that you want to be removed
add_filter('wooptpm_order_items', function ($order_items, $order){
foreach($order_items as $item_id => $item ){
$product = $item->get_product();
if($product->get_id() === 14 && $item->get_total() == 0) unset($order_items[$item_id]);
}
return $order_items;
}, 2, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment