Adding delivery address to woocommerce new order email - wordpress

I have a WordPress website with Woocommerce installed.
How can I add delivery address to the 'new order' email sent to admins? I have found how to edit this email but can't find the correct syntax.
Thanks

Please try putting this snippet in you active themes functions.php
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_details_to_admin_emails', 15, 2 );
function wc_add_shipping_details_to_admin_emails( $order, $is_admin_email ) {
if ( $is_admin_email ) {
<p><?php echo $order->get_formatted_shipping_address(); ?></p>
}
}

In the dashboard go to Woocommerce -> Settings -> Emails and then click on the gear button in the new order email column. There will be a field to input the address. You can input multiple emails in this field, just separate them with a comma.

Related

How to remove name in WooCommerce customer emails

for some reason the emails being sent to customers after they create a WooCommerce account displays a random name (see attached).
WooCommerce username error
I think because users can create an account with just an email address? But anyway - I want to just remove the Hi xxxx from all email communication from the customer. How do I do this? I am looking at the email templates but can't see how this code is generated?
To remove the name from email communication, you need to copy the email template file in your theme directory (e.g - customer-processing-order.php) on this find the below code:
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
And replace with the below mentioned code:
<p><?php printf( esc_html__( 'Hi,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
Same thing you can do for following Woocommerce email template files:
customer-completed-order.php
customer-completed-order.php
customer-invoice.php
customer-note.php
customer-on-hold-order.php
customer-processing-order.php
customer-refunded-order.php
Thanks - yes that solved the issue. The problem occurred because of a plugin conflict with a translation plugin. Thanks for the response to the question.

modify the woocommerce customer email

i have a website that uses woocommerce as a shopping car, usually they customer can choose different types of delivery, one of them is Local Pickup, we want the address where you can pick up your items and the time when you can pick it up to be sent in the email that the customer receive after he check out, but only if they choose local pick up these information will be sent to avoid confusion to the customer.
any idea where i can modify the text that goes out with the email, ill include a screen shot to know what i am talking about
email screenshot
Hello you can not do this with any e-mail edits because of woocommerce emails are set for the order statuses, not to the shipping methods. You could do it with code implementation into your theme's functions.php file.
Explanation: You need to add action before woocommerce email order table and set function for this action. In your function you will track your order's shipping method and if it match with local pickup then it adds extra text before the order table.
Do not forget to change this to your custom text echo '<h2 class="email-upsell-title">Local pickup instructions</h2><p class="email-upsell-p">Your text goes here for the local pickup info</p>';
UPDATE
add_action( 'woocommerce_email_before_order_table', 'localpickup_extra_info', 10, 4 );
function localpickup_extra_info( $order, $sent_to_admin, $plain_text, $email ) {
if ( $email->id == 'customer_processing_order' ) {
foreach( $order->get_items('shipping') as $shipping_item ){
$shipping_rate_id = $shipping_item->get_method_id();
$method_array = explode(':', $shipping_rate_id );
$shipping_method_id = reset($method_array);
if( 'local_pickup' == $shipping_method_id ){
echo '<h2 class="heading-title">Local pickup instructions</h2><p class="local-text">Your text goes here for the local pickup info</p>'; //change this
break;
}
}
}
}

Show different Woocommerce Thank you Message & New Order Email

I need assistance with customizing a woocommerce thankyou.php file and new-order.php file.
I want to show an image before a zapper gateway instructions on the thank you email and also show it on the email sent to client for payment.
I have the image showing problem in the thankyou.php page but its also showing on all payment gateways not only on the zapper gateway and its not showing on the new-order email sent to client.
here is the code for the thankyou.php
<?php if ( $order->get_payment_method_title() === 'zapper' ); ?> <div class="zapper"> <?php echo '<p style="margin-top:0;"><img src="webiste.com/wp-content/uploads/2017/10/zapper-process.j‌​pg"; /></p>'; ?>
Regards
Bongani
You can use a specific hook for your payment gateway woocommerce_thankyou_{payment gateway}.
add_action( 'woocommerce_thankyou_zapper', 'message_for_zapper', 5 );
function message_for_zapper( $order_id ) {
echo '<div class="zapper"><p style="margin-top:0;"><img src="webiste.com/wp-content/uploads/2017/10/zapper-process.j‌​pg" /></p>';
}
More examples here https://rudrastyh.com/woocommerce/thank-you-page.html#add_form

customizing woocommerce address fields

I want to edit, or add some fields to, woocommerce billing and shipping address in checkout page, profile page and everywhere in which the fields are displayed.
can anybody help me?
revving an old question but
function override_default_address_fields( $fields ) {
unset($fields['company']);
foreach($fields as $key => $value) {
$fields[$key]['label_class'] = 'sr-only';
}
return $fields;
}
add_filter( 'woocommerce_default_address_fields', 'override_default_address_fields' );
all the available fields can be found in includes/class-wc-countries.php -> public function get_default_address_fields()
It's very simple to edit or add new fields in woo commerce checkout page you can try with hard code and with woo commerce checkout field editor plugin

woocommerce_email_actions not working in custom plugin

I am trying to send a email when a order is moved to a custom status in woocommerce. I have successfully created a plugin that creates a custom status and order is assigned to the custom status.
I have also successfully added a custom email template under Settings -> Emails in WooCommerce and written code which should send a email when the order is moved to that custom status.
However that code is not getting triggered and email is not getting sent.
Below is my code.
apply_filters( 'woocommerce_email_actions', array('woocommerce_order_status_processing_to_partial-shipment'));
// Trigger on new paid orders
add_action( 'woocommerce_order_status_processing_to_partial-shipment_notification', array( $this, 'trigger' ) );
the action never comes in the trigger function i have written. I am using wordpress 4.5.3 and woocommerce version 2.6.4.
Can anyone suggest as to what could be going wrong. Thanks.
Since WooCommerce 2.3, you can use 'woocommerce_email_actions' filter, so you can try this:
function new_woocommerce_email_actions( $actions ){
$actions[] = 'woocommerce_order_status_processing_to_partial-shipment_notification';
return $actions;
}
add_filter( 'woocommerce_email_actions', 'new_woocommerce_email_actions' );
Luck

Resources