Skip to content

Instantly share code, notes, and snippets.

@advokatb
Created September 19, 2019 10:41
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 advokatb/4dcea7e91eaa6f646d393b7939c065bb to your computer and use it in GitHub Desktop.
Save advokatb/4dcea7e91eaa6f646d393b7939c065bb to your computer and use it in GitHub Desktop.
WooCommerce New order notification if order total bigger than value
<?php
// New order notification if order total bigger than value
add_action( 'woocommerce_checkout_order_processed', 'devise_email_if_ordertotal_bigger_than', 20, 1 );
function devise_email_if_ordertotal_bigger_than ( $order_id ) {
$order = wc_get_order( $order_id );
$total = $order->get_total();
$total_over = 500;
$admin_email = get_option( 'admin_email' );
$email_subject = 'ORDER OVER 500';
$email_body = 'New order over $500 is placed on shop';
// if total is greater than
if ( $total >= $total_over ) {
wp_mail( $admin_email, $email_subject , $email_body );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment