I got a quick question as I've been researching a couple of hours and have not found a suitable answer.
Id like to send a new type of e-mail when a new order is made and send it to the email address provided in a custom check-out field.
I've implemented Woocommerce and added extra checkout-fields via the plugin (Checkout Field Editor.
One of these check-out fields holds an email address (field name is [client_email]).
I also managed to create a new type of e-mail via the Woo Custom Emails Plugin.
The only problem I have is to set the recipient for this email with the input from the custom checkout field [client_email].
Any thoughts or solutions?
Many thanks!
I'd find this little snippet:
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'processing_order_replacement_email_recipient', 10, 2 );
function processing_order_replacement_email_recipient( $recipient, $order ) {
// Set HERE your replacement recipient email(s)… (If multiple, separate them by a coma)
$recipient = '<email adress>';
return $recipient;
}
And this is the e-mail template file.
<?php
/**
* Customer processing order email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-processing-order.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #author WooThemes
* #package WooCommerce/Templates/Emails
* #version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$email_heading = get_option( 'ec_woocommerce_customer_processing_order_heading' );
/**
* #hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php echo get_option( 'ec_woocommerce_customer_processing_order_main_text' ); ?>
<?php
/**
* #hooked WC_Emails::order_details() Shows the order details table.
* #hooked WC_Structured_Data::generate_order_data() Generates structured data.
* #hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* #since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::customer_details() Shows customer details
* #hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
Related
I'm looking for the easiest way to remove this tracking number tablefrom a transactional email in woocommerce.
Image attached to show what I mean.
I understand it's pulled from a function, but I don't know how to edit it without destroying the rest of the table, which I need to stay as is.
I'm not a coder, but I can follow instructions. Could tell me where I need to go and which parts to change. I could probably find my way into the function file, but I don't know how to edit it safely or what to delete/change.
<?php
/*
* #hooked WC_Emails::order_details() Shows the order details table.
* #hooked WC_Structured_Data::generate_order_data() Generates structured data.
* #hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* #since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/*
* #hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/*
* #hooked WC_Emails::customer_details() Shows customer details
* #hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/*
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
I am trying to remove info above the table about order from processing order email in woocommerce. In customer-processing-order.php i found this hook:
/*
* #hooked WC_Emails::order_details() Shows the order details table.
* #hooked WC_Structured_Data::generate_order_data() Generates structured data.
* #hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* #since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
How to remove the first hooked function from processing order email notification (to get blank order info I suppose)?
You can use the following to remove order details from WooCommerce processing email notification sent to customer:
add_action( 'woocommerce_email_order_details', 'action_email_order_details', 2, 4 );
function action_email_order_details( $order, $sent_to_admin, $plain_text, $email ) {
// Targeting "processing" order email notification sent to customer.
if ( 'customer_processing_order' === $email->id ) {
remove_action( 'woocommerce_email_order_details', array( WC()->mailer(), 'order_details' ) );
}
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
I need to remove the following from the Customer Processing Order email that WooCommerce sends customers once they have placed an order:
Payment Type
Price of items purchased
Everything that sits within the table below the items purchased, i.e. Total and Notes.
I've attached an image for a visual look at what needs ot be removed from the email:
items to be removed:
The file is found here: yourtheme/woocommerce/emails/customer-processing-order.php and it contains the code below but as you can see it's not a simple case of remove or comment out sections.:
<?php
/**
* Customer processing order email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-processing-order.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce/Templates/Emails
* #version 3.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* #hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s: Customer first name */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
<?php /* translators: %s: Order number */ ?>
<p><?php printf( esc_html__( 'Just to let you know — we\'ve received your order #%s, and it is now being processed:', 'woocommerce' ), esc_html( $order->get_order_number() ) ); ?></p>
<?php
/*
* #hooked WC_Emails::order_details() Shows the order details table.
* #hooked WC_Structured_Data::generate_order_data() Generates structured data.
* #hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* #since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/*
* #hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/*
* #hooked WC_Emails::customer_details() Shows customer details
* #hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/**
* Show user-defined additional content - this is set in each email's settings.
*/
if ( $additional_content ) {
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
}
/*
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
I've also used the following code in my functions.php file to remove the Subtotal and just below that, the Payment Method. But I still need help removing the other items.
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );
function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
unset( $totals['payment_method'] );
return $totals;
}
you can custom the content using woocommerce_email_before_order_table hook
add_action( 'woocommerce_email_before_order_table', 'custom_process_table', 10, 4 );
function custom_process_table( $order, $sent_to_admin, $plain_text, $email ) {
// Your Custom Table goes here
}
you can also override the email template.
https://github.com/woocommerce/woocommerce/blob/master/templates/emails/email-order-details.php
I am trying to find a way to add the Authorize.net ID (not the woocommerce customer ID) to the admin order template. The Authorize.net ID shows on the order screen:
I want that ID # to go in the email. Here is the e-mail template:
<?php
/**
* Admin new order email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-new-order.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #author WooThemes
* #package WooCommerce/Templates/Emails/HTML
* #version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* #hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>
<?php
/**
* #hooked WC_Emails::order_details() Shows the order details table.
* #hooked WC_Structured_Data::generate_order_data() Generates structured data.
* #hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* #since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email, $transaction_ID );
/**
* #hooked WC_Emails::customer_details() Shows customer details
* #hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
Any ideas? I appreciate any guidance I can get.
This code will display the transaction ID (when it exists) in Woocommerce admin email notifications:
// Display the payment gateway transwaction ID on email notifications
add_action('woocommerce_email_order_details', 'before_email_order_details_transaction_id', 5, 4 );
function before_email_order_details_transaction_id( $order, $sent_to_admin, $plain_text, $email ) {
if( $order->get_transaction_id() && $sent_to_admin )
echo '<p><strong>' . __("Transaction id") . ': </strong>' . $order->get_transaction_id() . '<p>';
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
In my WooCommerce web shop, I am using WooCommerce Subscriptions plugin.
I am trying to remove the hyperlink from a woocommerce email template:
I don't see how I can do this from the template below:
<?php
/**
* Customer processing order email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-processing-order.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #author WooThemes
* #package WooCommerce/Templates/Emails
* #version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* #hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<p><?php _e( "Your order has been received and is now being processed. Your order details are shown below for your reference:", 'woocommerce' ); ?></p>
<?php
/**
* #hooked WC_Emails::order_details() Shows the order details table.
* #hooked WC_Structured_Data::generate_order_data() Generates structured data.
* #hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* #since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::customer_details() Shows customer details
* #hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/**
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
There are no href in the code below, in order to remove said link.
How can I remove this hyperlink?
Thanks
You need to copy the template located in the your subscription plugin:
woocommerce-subscriptions/templates/email/subscriptions-info.php
to your active chlid theme folder (or active theme folder):
your-theme/woocommerce/email/subscriptions-info.php
To understand WooCommerce templates:
Template Structure + Overriding Templates via a Theme
Once done you can change the code in this template at line 27 from here:
<td class="td" scope="row" style="text-align:left;"><?php echo sprintf( esc_html_x( '#%s', 'subscription number in email table. (eg: #106)', 'woocommerce-subscriptions' ), esc_html( $subscription->get_order_number() ) ); ?></td>
Replacing by this:
<td class="td" scope="row" style="text-align:left;"><?php echo sprintf( esc_html_x( '#%s', 'subscription number in email table. (eg: #106)', 'woocommerce-subscriptions' ), esc_html( $subscription->get_order_number() ) ); ?></td>
This is tested and works on WooCommerce 3+