Last active
June 8, 2020 07:09
-
-
Save iamsathyaseelan/2ed79fad0a8184e7d5dbeb7883636973 to your computer and use it in GitHub Desktop.
remove next ordercoupon in order notification email
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
add_filter('rnoc_before_displaying_next_order_coupon', "rnoc_before_displaying_next_order_coupon", 10, 2); | |
/** | |
* @param $message | |
* @param $order \WC_Order | |
* @return string | |
*/ | |
function rnoc_before_displaying_next_order_coupon($message, $order) | |
{ | |
if (method_exists($order, 'get_billing_email')) { | |
$order_email = $order->get_billing_email(); | |
$args = array( | |
'meta_key' => 'email', | |
'meta_value' => $order_email, | |
'post_type' => 'rnoc_order_coupon', | |
'posts_per_page' => -1 | |
); | |
$posts = get_posts($args); | |
if (count($posts) == 1) { | |
return $message; | |
} else { | |
$message = ""; | |
} | |
} | |
return $message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment