Следующие функции объединят обе функции в одну:
add_action( 'woocommerce_before_customer_login_form', 'next_day_delivery' );
add_action( 'woocommerce_before_customer_login_form', 'next_day_delivery' );
add_action( 'woocommerce_before_checkout_form', 'next_day_delivery' );
add_action( 'woocommerce_before_shop_loop', 'next_day_delivery' );
add_action( 'woocommerce_before_single_product_summary', 'next_day_delivery' );
add_action( 'woocommerce_before_cart', 'next_day_delivery' );
function next_day_delivery() {
if( WC()->cart->is_empty() )
return; // Exit
// Set the time zone
date_default_timezone_set('Europe/Stockholm');
// From Monday to Thursday
$is_week_days = in_array( date('w'), array( 1, 2, 3, 4 ) ) ? true : false;
$end_time = mktime('12', '00', '00', date('m'), date('d'), date('Y'));
$now_time = time();
$after_tomorow = date('l', strtotime('+2 days'));
$dateDiff = intval(($end_time - $now_time)/60);
$diff_hours = intval($dateDiff/60);
$diff_minutes = $dateDiff%60;
$hours_label = _n( 'hour', 'hours', $diff_hours, 'wooocommerce' );
$minutes_label = _n( 'minute', 'minutes', $diff_minutes, 'wooocommerce' );
$minutes_displ = $diff_minutes.' '.$minutes_label;
$hours_display = $diff_hours.' '.$hours_label.' and ';
$remain_time = $diff_hours > 0 ? $hours_display . $minutes_displ : $minutes_displ;
$cart_total = WC()->cart->total;
$limit_free = 100; // Starting freee shipping amount
$free_shipping = ''; // Initialising
if ( $cart_total < $limit_free ) {
$free_shipping = sprintf(
__('%s If you spend another %s you will get %s', 'woocommerce' ),
'', // ' <img src="' . get_stylesheet_directory_uri() . '/images/shipping-icon.png"> ',
strip_tags( wc_price( round( $limit_free - $cart_total, 2 ) ) ),
'<strong>' . __( 'FREE SHIPPING!', 'woocommerce' ) . '</strong>'
);
} elseif ( $cart_total >= $limit_free ) {
$free_shipping = '<strong>' . __( ' You get FREE SHIPPING!', 'woocommerce' ) . '</strong>';
}
if ( $end_time > $now_time && $is_week_days ) {
// print the information notice
$message = sprintf( __( '%s left to be delivered tomorrow! %s', 'woocommerce' ), $remain_time, $free_shipping );
}
elseif ( $end_time <= $now_time && $is_week_days ) {
$message = sprintf( __( 'Your order will be delivered this %s. %s', 'woocommerce' ), $after_tomorow, $free_shipping );
} else {
$message = __( 'Your order will be prepared and shipped next upcoming monday and delivered on tuesday.', 'woocommerce' ) . $free_shipping;
}
wc_print_notice( $message, 'success' );
}
Код помещается в файл function.php вашей активной дочерней темы (или активной темы). Проверено и работает.


Обновление: Убраны часы, когда они равны нулю:

Чтобы использовать тег <p class="my-custom>
html вместо структуры уведомления Woocommerce, замените:
wc_print_notice( $message, 'success' );
по:
echo '<p class="my-custom>' . $message . '</p>';
Вы закончили ...