I came across this snippet that adds a coupon to the order mail.
I would like to make it appear in the processing order mail only if the customer have not used any coupon.
add_action( 'woocommerce_email_before_order_table', 'add_content', 20 );
function add_content() {
echo '<h2 id="h2thanks">Get 20% off</h2><p id="pthanks">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase! Click here to continue shopping.</p>';
}
Thanks.
This code is tested and fully functional
Yes it is possible easily adding an
if
statement with 2 conditions.The first one detect if a coupon has not been used in the order used in the order:
And the second one will detect if the order is in "processing" status:
If that conditions are matched, your message is displayed using**
'woocommerce_email_before_order_table'
** hook:Here is your customized code snippet:
This code goes on function.php file of your active child theme or theme
This code is tested and fully functional