Last active
May 4, 2023 10:04
-
-
Save damiencarbery/f77b8aa18107290825058a2f7ca4e1e3 to your computer and use it in GitHub Desktop.
Add info to WooCommerce order emails -
This file contains 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 | |
/* | |
Plugin Name: Custom note to order email | |
Plugin URI: https://www.damiencarbery.com/2018/07/add-info-to-woocommerce-order-emails/ | |
Description: Add a note to the order email if the order contains products from the specified category. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
/* Add note about shapetrousers delivery time to the order email. */ | |
add_action( 'woocommerce_email_order_details', 'am_shapetrousers_delivery_info_to_order_email', 5, 4 ); | |
function am_shapetrousers_delivery_info_to_order_email( $order, $sent_to_admin, $plain_text, $email ) { | |
// Only customers need to know about the delivery times. | |
if ( $sent_to_admin ) { | |
return; | |
} | |
$order_has_shapetrousers_product = false; | |
$items = $order->get_items(); | |
foreach ( $items as $item_id => $item ) { | |
$product = $item->get_product(); | |
if ( $product->is_type( 'variation' ) ) { | |
$product = wc_get_product( $product->get_parent_id() ); | |
} | |
if ( has_term( 'shapetrousers', 'product_cat', $product->get_id() ) ) { | |
$order_has_shapetrousers_product = true; | |
} | |
} | |
if ( $order_has_shapetrousers_product ) { | |
if ( $plain_text ) { | |
echo "\nNOTE: Shapetrousers products are custom made so please allow 10 days for delivery.\n"; | |
} | |
else { | |
echo '<p><strong>Note</strong>: Shapetrousers products are custom made so please allow 10 days for delivery.</p>'; | |
} | |
} | |
} |
This file contains 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 | |
do_action( 'woocommerce_email_header', $email_heading, $email ); | |
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); | |
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); | |
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); |
This file contains 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 | |
/* | |
Plugin Name: Note for Processing email | |
Plugin URI: https://www.damiencarbery.com/2018/07/add-info-to-woocommerce-order-emails/ | |
Description: Add a note to the processing order email only. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
add_action( 'woocommerce_email_order_details', 'am_note_for_processing_order_email', 5, 4 ); | |
function am_note_for_processing_order_email( $order, $sent_to_admin, $plain_text, $email ) { | |
// Only customers need to know about the delivery times. | |
if ( $sent_to_admin ) { | |
return; | |
} | |
if ( 'customer_processing_order' == $email->id ) { | |
if ( $plain_text ) { | |
echo "\n** We are working on your order right now. It is our top priority - we will skip meals to get it ready for you!\n"; | |
} | |
else { | |
echo '<p>We are working on your order <strong>right now</strong>. It is our <strong>top priority</strong> - we will skip meals to get it ready for you!</p>'; | |
} | |
} | |
} |
This file contains 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 | |
/* | |
Plugin Name: Add tracking info to Completed Order email | |
Plugin URI: https://www.damiencarbery.com/2018/07/add-info-to-woocommerce-order-emails/ | |
Description: Add tracking info to the Complete Order email (replying to Joel's comment). | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
add_action( 'woocommerce_email_customer_details', 'dcwd_add_tracking_info_to_completed_order_email', 30, 4 ); | |
function dcwd_add_tracking_info_to_completed_order_email( $order, $sent_to_admin, $plain_text, $email ) { | |
if ( 'customer_completed_order' != $email->id ) { | |
return; | |
} | |
if ( $sent_to_admin ) { | |
return; | |
} | |
echo '<p>This is where you will put the tracking info for the package for ', $order->get_formatted_billing_full_name(),'.</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment