• Resolved eosonwp

    (@eosonwp)


    Hi there,

    My client is running his business until 2am midnight, so he wants his revenue reports for 12am – 2am to stay within previous day.

    I have tried to change the WordPress timezone at WordPress>Setting>General, but it is not working. May I know how can I set it?

    Thank You

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    You can format the chart?by hour only if the range is 1 day, and even then you can’t limit it to certain hours.

    You can submit this as an enhancement request in?GitHub. ??

    In case I misunderstood, can you please elaborate more?

    Best Regards,

    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @eosonwp,

    One should be able to achieve this by adjusting the time zone but the shortcoming is that it won’t affect the client’s time zone. This best approach is to use custom functions for order dates. An example is in the code below:

    function adjust_order_date_based_on_business_hours( $date ) {
    $client_business_start_time = 0; // Midnight
    $client_business_end_time = 2; // 2AM
    $current_time = current_time( 'timestamp' );

    // Check if the current time is between midnight and 2am
    if ( date( 'H', $current_time ) >= $client_business_start_time && date( 'H', $current_time ) < $client_business_end_time ) {
    // Adjust the date to the previous day
    $date = date( 'Y-m-d H:i:s', strtotime( '-1 day', strtotime( $date ) ) );
    }

    return $date;
    }
    add_filter( 'woocommerce_order_get_date_created', 'adjust_order_date_based_on_business_hours' );

    The code adjusts the order date for nay orders created between midnight and 2am, making them count under the previous day.

    An alternative no code option is to use custom reporting plugin that allows adjusting timezones. Please note that providing code support is outside the support scope of the forum. The code above is just to give you an idea of what is possible. If you need help getting this done, it is best to hire an expert.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.