Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // TODO: look into basing this off order value.
  2.  
  3. //add_filter( 'woocommerce_email_enabled_new_renewal_order', 'unhook_those_pesky_emails', 20, 2 );
  4. //add_filter( 'woocommerce_email_enabled_customer_renewal_invoice', 'unhook_those_pesky_emails', 20, 2 );
  5. add_filter( 'woocommerce_email_enabled_customer_new_order', 'unhook_those_pesky_emails', 20, 2 );
  6. function unhook_those_pesky_emails( $active, $order ) {
  7.  
  8. //var_dump($order);
  9. //exit;
  10.  
  11. if ( ! isset($order) ) {
  12. return $active;
  13. }
  14.  
  15. var_dump($order);
  16.  
  17. $items = $order->get_items();
  18. $active = false;
  19.  
  20. foreach ( $items as $item ) {
  21.  
  22. if ( isset( $item['variation_id'] ) ) {
  23. $product = wc_get_product( $item['variation_id'] );
  24. } else {
  25. $product = wc_get_product( $item['product_id'] );
  26. }
  27.  
  28. $price = $product->get_price();
  29.  
  30. if ( 0 != $price ) {
  31. $active = true;
  32. break;
  33. }
  34. }
  35.  
  36. return $active;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement