• Resolved mic6

    (@mic6)


    I noticed that a few of my orders was missing the complete date.
    So i’ll need to insert those manually in the database through a php script.
    But noticed that there was 2 fields for it.
    _completed_date
    _date_completed

    Do I need to use both, and could someone provide an sql example query for update these fields?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Are you sure the orders are completed? What about editing the order, and setting the status to completed again, manually?

    I believe there are two metas for backwards compatibility reasons. WC 3.0 (was originally tagged at 2.7) made changes to how dates were stored, some history here: https://github.com/woocommerce/woocommerce/issues/13498

    The safest way, moving forward, would be to use the methods on the order object to update these values. So $order_object->set_date_completed( '2018-08-25' ) for example.

    So could get a list of order IDs with no completed date, then loop through them all and set a date (hopefully based on another date that was stored already).

    Thread Starter mic6

    (@mic6)

    Thanks Caleb, very good suggestion

    Thread Starter mic6

    (@mic6)

    For some reason it’s not quite working.
    I tried with set_date_completed( ‘2018-08-25’ ) and the one below, no difference, no errors, but no changes to order date. If i print out the order details, I can see it’s the right order it’s trying to change.

    function change_order_details() {
    $order_id=115;
    $order = wc_get_order( $order_id );
    $order->set_date_completed( ‘2017-10-16 13:48:10’ );
    }
    add_action( ‘wp_head’, ‘change_order_details’ );

    Am i missing something?

    Thread Starter mic6

    (@mic6)

    @icaleb any idea what could be wrong?

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Need to save after.

    
    $order->save();
    
    Thread Starter mic6

    (@mic6)

    Ah of course.. Thanks working perfectly now.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Complete Date’ is closed to new replies.