'Remove duplicated date in Woocommerce product page

I'm using "Woo estimated shipping date" plugin to sell pre-order products with estimated shipping date but the pluging show the message plus the date, and I need to show only the message not the "06/04/2022:

enter image description here

That is given by the product page editor option in "Estimated Delivery Time in Days":

enter image description here

Here's the plugin code:

 <?php

 namespace Saimon\WCESD\Views;

 use Saimon\WCESD\Date_Calculator;
 use Saimon\WCESD\Helper;

defined( 'ABSPATH' ) || exit;

class Single_Product {

public function __construct() {
    $this->hooks();
}

private function hooks() {
    add_action( 'woocommerce_after_add_to_cart_form', [ self::class, 'show_date' ] );
}

public static function show_date() {
    if ( 'yes' !== Helper::get_option( 'wc_esd_date_enable' ) ) {
        return;
    }

    $wc_esd_date         = Helper::get_option( 'wc_esd_date' );
    $wc_esd_date         = $wc_esd_date ? $wc_esd_date : 5;
    $wc_esd_date_message = Helper::get_option( 'wc_esd_date_message' );
    $wc_esd_date_message = $wc_esd_date_message ? $wc_esd_date_message : __( 'Estimated Delivery Date', 'wcesd' );
    $today               = strtotime( current_time( 'mysql' ) );
    $to_date             = '';

    if ( Helper::is_weekend_excluded() ) {
        $date = ( new Date_Calculator( $today, $wc_esd_date ) )->get_date();

        if ( Helper::is_date_range_enabled() ) {
            $wc_esd_date = $wc_esd_date + Helper::get_date_range_gap();
            $to_date = ( new Date_Calculator( $today, $wc_esd_date ) )->get_date();
        }
    } else {
        $date = ( new Date_Calculator( $today, $wc_esd_date, false ) )->get_date();

        if ( Helper::is_date_range_enabled() ) {
        $wc_esd_date = $wc_esd_date + Helper::get_date_range_gap();
        $to_date = ( new Date_Calculator( $today, $wc_esd_date ) )->get_date();
        }
    }

    if ( ! empty( $to_date ) ) {
        $message = $wc_esd_date_message . ' ' . Helper::display_date( $date ) . ' - ' . Helper::display_date( $to_date );
    } else {
        $message = $wc_esd_date_message . ' ' . Helper::display_date( $date );
    }

    $html = '<div class="wesd-box">';
    $html .= '<strong class="shipper-date">';
    $html .= $message;
    $html .= '</strong>';
    $html .= '</div>';

    echo wp_kses_post(
        $html
    );
}
}

And I need to achieve this:

enter image description here

The problem is if I don't put a day in the "Estimated delivery time in days" field, the system use a default 5 days time and put the date again (06/04/2022) again.

Any idea how to achieve this guys? Thank you very much.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source