Skip to content

Instantly share code, notes, and snippets.

@justinstern
Created June 4, 2013 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinstern/5706113 to your computer and use it in GitHub Desktop.
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
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