Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement