Skip to content

Instantly share code, notes, and snippets.

@kloon
Created December 5, 2013 09:36
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kloon/7802618 to your computer and use it in GitHub Desktop.
WooCommerce add shipping method to emails
<?php
// Place the following code in your theme's functions.php file to add the shipping method to all emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_emails', 15, 2 );
function wc_add_shipping_method_to_emails( $order, $is_admin_email ) {
echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>';
}
// Place the following code in your theme's functions.php file to add the shipping methid to admin emails only
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_admin_emails', 15, 2 );
function wc_add_shipping_method_to_admin_emails( $order, $is_admin_email ) {
if ( $is_admin_email ) {
echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>';
}
}
?>
@nlmosler
Copy link

I was wondering how this could be added as a separate plugin so that if the theme is updated it does not get wiped away.

@auludag
Copy link

auludag commented May 2, 2020

I was wondering how this could be added as a separate plugin so that if the theme is updated it does not get wiped away.

You can use code snippets plugin and add this into there, so it doesn't get wiped away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment