I am trying to tack on estimated arrival times to the labels of my shipping methods. However, I'd like the arrival times to have some bonus HTML within the label. (Make them smaller and different font-weight).
Here is a simple example:
function add_estimated_arrival_times($rates, $package){
$groundStuff = $timeReturnedFromAPI; //collect a bunch of cart information, post to the UPS API, return estimated arrival time to $timeReturnedFromAPI
$ground_rate_id = 'ups:6:09'; //UPS ground rate ID
// Loop through available shipping rates, add arrival time if rate is UPS ground
foreach ( $rates as $rate_key => $rate ) {
if( $ground_rate_id === $rate_key ) {
$rates[$rate_key]->label .= ' <span style="font-size: 12px; font-weight: normal;">(' . $groundStuff . ')</span>'; //<---- problem: HTML is not added
break;
}
}
return $rates;
}
add_filter( 'woocommerce_package_rates','add_estimated_arrival_times', 50, 2 );
The code above successfully adds the plain text to the shipping method label, but the HTML disappears.
What would be a good workaround for this?