• Resolved pmcelwee

    (@pmcelwee)


    I have imported orders successfully, but the imported orders seem to be missing an order_key. Has this been seen before?

    I have noticed it because download links on a My-Account > Order page are broken. If I log the order, I can see that order_key is blank.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @pmcelwee,

    Sorry for the inconvenience caused.

    We will look into it and fix it in the upcoming update.

    Thread Starter pmcelwee

    (@pmcelwee)

    Thanks for looking into it, though while I’m glad it will be fixed for other users, to be honest, an update won’t solve my issue, since my import is complete. Any clues on how to fix it now would be much appreciated!

    Thread Starter pmcelwee

    (@pmcelwee)

    The problem is that the import didn’t add meta_data to the order with the key _order_key. (It *did* correctly add an order key to the order itself.)

    For others who may come across this, I was able to fix it with this SQL statement, which fixed over 59,000 orders in about 33 seconds (the post_password column is where Woocommerce stores the order_key):


    INSERT INTO
    wp_postmeta(post_id, meta_key, meta_value)
    SELECT
    wp_posts.ID,
    '_order_key',
    wp_posts.post_password
    FROM wp_posts
    WHERE post_type = 'shop_order'
    AND NOT EXISTS(
    SELECT 1
    FROM wp_postmeta
    WHERE post_id = wp_posts.ID AND meta_key = '_order_key'
    )

    • This reply was modified 2 years, 9 months ago by pmcelwee.
    • This reply was modified 2 years, 9 months ago by pmcelwee.
    • This reply was modified 2 years, 9 months ago by pmcelwee.
    Plugin Author WebToffee

    (@webtoffee)

    Hi @pmcelwee,

    Happy to see you have found a solution and that you have shared it here so that others would benefit from it.

    Have a good day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘missing order_key for imported orders’ is closed to new replies.