Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active April 22, 2024 12:35
Show Gist options
  • Select an option

  • Save hedqvist/8f49c219c6e6137a6680d0a6c56f766a to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/8f49c219c6e6137a6680d0a6c56f766a to your computer and use it in GitHub Desktop.
Unifaun/Pacsoft - Add track and trace to completed email
<?php
/**
* @snippet WooCommerce - Unifaun plugin by Redlight Media - Add Track & Trace url to completed email
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.8.1
*/
function redlight_add_tracking_url_to_completed_email( $order, $sent_to_admin, $plain_text, $email ) {
if ( $email->id == 'customer_completed_order' ) {
if (function_exists('wcuns')) {
$track_and_trace_url = sprintf(
'<strong>%1$s</strong> <a href="%2$s" target="_blank">%3$s</a>',
__( 'För att spåra din försändelse så kan du använda följande länk:'),
wc_clean( wcuns()->generate_track_and_trace_url( $order->get_id() ) ),
__( 'Spårningslänk' )
);
echo '<p>' . $track_and_trace_url . '</p>';
}
}
}
add_action( 'woocommerce_email_before_order_table', 'redlight_add_tracking_url_to_completed_email', 20, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment