Created
March 16, 2021 12:23
-
-
Save railmedia/94da2e9abc381803269174aee7a20ce4 to your computer and use it in GitHub Desktop.
WooCommerce send email when specific coupon is applied in the order
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 | |
| 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