Created
June 4, 2013 13:56
-
-
Save justinstern/5706113 to your computer and use it in GitHub Desktop.
Filter to mark an order as not free if any of the items have a regular price (ie the order is only "free" because of coupons or discounts) for the WooCommerce Sequential Order Numbers plugin
This file contains 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
add_filter( 'wc_sequential_order_numbers_is_free_order', 'wc_sequential_order_numbers_is_free_order', 10, 2 ); | |
function wc_sequential_order_numbers_is_free_order( $is_free, $order_id ) { | |
if ( $is_free ) { | |
$order = new WC_Order( $order_id ); | |
// lets make sure the items truly are free, and not just on sale, or discounted with a coupon | |
foreach ( $order->get_items() as $item ) { | |
$product = $order->get_product_from_item( $item ); | |
if ( $product->regular_price > 0 ) return false; | |
} | |
} | |
return $is_free; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment