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+
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 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 create a review reminder email using the Customer invoice / Order details email. We don't use this email so I thought it would be good to change the code to make it a review reminder email and then we can trigger it manually.
I have changed a bit of code, so it now looks like this:
<?php
/**
* Customer completed order email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-completed-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.5.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>
<p><?php printf( esc_html__("the more you share, the more you help other customers. We would love to know your thoughts on your most recent purchase and we'd appreciate it if you could take a moment to write a quick review.", 'woocommerce' ), esc_html( wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) ); ?></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
*/
$text_align = is_rtl() ? 'right' : 'left';
if ( $sent_to_admin ) {
$before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
$after = '</a>';
} else {
$before = '';
$after = '';
}
/* translators: %s: Order ID. */
?>
</h2>
<div style="margin-bottom: 40px;">
<table class="td" cellspacing="0" cellpadding="0" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
<tbody>
<?php
echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
'show_sku' => $sent_to_admin,
'show_image' => true,
'image_size' => array( 100, 100 ),
'plain_text' => $plain_text,
'sent_to_admin' => $sent_to_admin,
) );
?>
</tbody>
</table>
</div>
<p>
<?php esc_html_e( 'Thanks for shopping with us.', 'woocommerce' ); ?>
</p>
<?php
/*
* #hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
I need to add 3 things though:
A static image, below the header, pointing to an image in the media library.
A URL link to the particular product purchased.
This query gives me the product name (and image), quantity and price. I want to get rid of quantity and price and just have the name and image.
I don't want to mess with the main email template code though, so I want to be able to do these things all within this one php file.
Can someone please advise on any of these three items? Thanks!
Copy the email-order-items.php form plugins/woocommerce/templates/emails/ to your wp-content/themefolder/woocommerce/emails/email-order-item.php by doing this you can edit the layout of your email without touching the core functions of woocommerce. The details are already there including the image and the title.
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.
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 );