Hi, @simppa999,
Glad to hear we figured out the cause of the problem.
Now, regarding the solution – the first thing that comes to mind – recreate our own attach_tracking_to_email()
callback (from the class-admin.php
file). It should look like this (I didn’t test it, though):
add_action( 'plugins_loaded', function () {
if ( wp_doing_cron() ) {
add_action( 'woocommerce_email_order_meta', function ( $order, $sent_to_admin = false, $plain_text = false, $email = null ) {
// Must be a "Completed order" email
if ( ! isset( $email->id ) || 'customer_completed_order' !== $email->id ) {
return;
}
// Get labels
$labels = $order->get_meta( '_wc_pakettikauppa_labels' );
if ( empty( $labels ) ) {
return;
}
// Get tracking codes
$tracking_codes = array();
foreach ( $labels as $label ) {
if ( ! empty( $label['tracking_code'] ) ) {
array_push(
$tracking_codes,
array(
'code' => $label['tracking_code'],
'url' => $label['tracking_url'],
'point' => $label['pickup_name'],
)
);
}
}
if ( empty( $tracking_codes ) ) {
return;
}
// Output
$add_pickup_point_to_email = 'yes'; // Change this to 'no' if needed
?><h2><?php esc_attr_e( 'Tracking', 'woo-pakettikauppa' ); ?></h2><?php
foreach ( $tracking_codes as $code ) {
?><p><?php
if ( 'yes' === $add_pickup_point_to_email ) {
if ( ! empty( $code['point'] ) ) {
?><b><?php esc_attr_e( 'Pickup point', 'woo-pakettikauppa' ); ?></b>
<?php esc_attr( $code['point'] ); ?><br/><?php
} else {
?><b><?php esc_attr_e( 'Pickup point', 'woo-pakettikauppa' ); ?> :</b> —<br/><?php
}
}
echo sprintf(
__( 'You can %1$s with tracking code %2$s.', 'woo-pakettikauppa' ),
'<a href="' . esc_url( $code['url'] ) . '">' . __( 'track your order', 'woo-pakettikauppa' ) . '</a>',
'<b>' . esc_attr( $code['code'] ) . '</b>'
);
?></p><?php
}
}, 10, 4 );
}
} );
Please give it a try and let me know what you think. And if you like the plugin, please consider leaving me a rating.