• Resolved marciosironi

    (@marciosironi)


    I have this function that shows all the Order Notes on the myaccount page.
    It’s working, but the timestamp is wrong. How can I insert the same timestamp that is configured in wordpress?

    function animers_woocommerce_order_details_before_order_table( $order ) { ?>
    <h2 class=”woocommerce-order-details__title”>Atualiza??es do Pedido</h2>
    <div class=”collapsible-orders”>
    <ul class=”order_notes” style=”display: flex; flex-direction: column-reverse;”>
    <?php
    $order_id = $order->get_id();

    $order_notes = get_private_order_notes( $order_id );
    echo $order->get_status();
    if ( $order->get_status() == ‘completed’ || $order->get_status() == ‘processing’ ) :
    foreach($order_notes as $note) {
    $note_id = $note[‘note_id’];
    $note_date = $note[‘note_date’];
    $note_author = $note[‘note_author’];
    $note_content = $note[‘note_content’];

    $haystack = $note_content;

    ?>

    <li class=”note system-note”>
    <div class=”note_content”>
    <?php echo ”.$note_content.’
    ‘; ?>
    </div>
    <p class=”meta”>
    <abbr class=”exact-date” title=”<?php echo $note[‘note_date’]; ?>”><?php echo $note[‘note_date’]; ?>
    </abbr>

    <?php }

    endif; ?>

    </div>

    <?php }

    EDIT:
    I tried this code, but all notes have the current time, not the time the note was created.

    <?php echo date_i18n( esc_html__( ‘l jS \o\f F Y, h:ia’, ‘woocommerce’ ), strtotime( $note->comment_date ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>

Viewing 1 replies (of 1 total)
  • Thread Starter marciosironi

    (@marciosironi)

    I got it with this code

    <abbr class=”exact-date” title=”<?php printf( __( ‘added on %1$s at %2$s’, ‘woocommerce’ ), date_i18n( wc_date_format(), strtotime( $note[‘note_date’] ) ), date_i18n( wc_time_format(), strtotime( $note[‘note_date’] ) ) ); ?>”>
    <?php printf( __( ‘added on %1$s at %2$s’, ‘woocommerce’ ), date_i18n( wc_date_format(), strtotime( $note[‘note_date’] ) ), date_i18n( wc_time_format(), strtotime( $note[‘note_date’] ) ) ); ?>
    </abbr>

Viewing 1 replies (of 1 total)
  • The topic ‘Timestamp in Order Notes’ is closed to new replies.