Created
July 21, 2021 12:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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