Skip to content

Instantly share code, notes, and snippets.

@railmedia
Created March 16, 2021 12:23
Show Gist options
  • Select an option

  • Save railmedia/94da2e9abc381803269174aee7a20ce4 to your computer and use it in GitHub Desktop.

Select an option

Save railmedia/94da2e9abc381803269174aee7a20ce4 to your computer and use it in GitHub Desktop.
WooCommerce send email when specific coupon is applied in the order
<?php
add_action( 'woocommerce_thankyou', 'send_email_on_coupon_usage' );
function send_email_on_coupon_usage( $order_id ) {
$order = new WC_Order( $order_id );
$coupons = $order->get_coupon_codes();
if( $coupons ) {
foreach( $coupons as $coupon ) {
if( $coupon == '<YOUR_COUPON_CODE>' ) {
//Send email
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment