Created
September 19, 2019 10:41
-
-
Save advokatb/4dcea7e91eaa6f646d393b7939c065bb to your computer and use it in GitHub Desktop.
WooCommerce New order notification if order total bigger than value
This file contains hidden or 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
<?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