Created
September 30, 2016 15:19
-
-
Save gthayer/7835e800483ecce630fe7266e466933e to your computer and use it in GitHub Desktop.
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
// TODO: look into basing this off order value. | |
//add_filter( 'woocommerce_email_enabled_new_renewal_order', 'unhook_those_pesky_emails', 20, 2 ); | |
//add_filter( 'woocommerce_email_enabled_customer_renewal_invoice', 'unhook_those_pesky_emails', 20, 2 ); | |
add_filter( 'woocommerce_email_enabled_customer_new_order', 'unhook_those_pesky_emails', 20, 2 ); | |
function unhook_those_pesky_emails( $active, $order ) { | |
//var_dump($order); | |
//exit; | |
if ( ! isset($order) ) { | |
return $active; | |
} | |
var_dump($order); | |
$items = $order->get_items(); | |
$active = false; | |
foreach ( $items as $item ) { | |
if ( isset( $item['variation_id'] ) ) { | |
$product = wc_get_product( $item['variation_id'] ); | |
} else { | |
$product = wc_get_product( $item['product_id'] ); | |
} | |
$price = $product->get_price(); | |
if ( 0 != $price ) { | |
$active = true; | |
break; | |
} | |
} | |
return $active; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment