Woocommerce 5.5 unable to create order

Skip to content

WordPress.org

Search WordPress.org for:Submit

Skip to content

Support

Support » Plugin: WooCommerce » Unable to create order

Unable to create order

  • ResolvedSteveo123 (@steveo123)
    2 years, 11 months agoWe upgraded our dev site to Woocommerce 3.4.4. Since then when we try sending a test order through we are getting “Unable to create order” on the checkout page after we enter the billing information. I am not seeing anything in the logs. Any ideas?The page I need help with: [log in to see the link]

Viewing 13 replies – 1 through 13 (of 13 total)

  • Thread StarterSteveo123 (@steveo123)2 years, 11 months agoI also just noticed that for my test order I am not able to delete the item from my shopping cart.pierremouteau (@pierremouteau)2 years, 11 months agoSame problem here on a live shop, any news on the problem ?Thread StarterSteveo123 (@steveo123)2 years, 11 months agoI found some issues with my database. Auto increment was not set on some of the table primary keys. Now I’m getting a different error (internal server error). Still working on that one.Plugin SupportJohn Coy a11n (@johndcoy)Automattic Happiness Engineer2 years, 11 months agoHi @steveo123This isn’t something I’ve been ablet to replicate.After viewing your dev site’s checkout process I see that the console shows a few JS errors. Typically issues like this are caused by a theme or plugin conflict. try switching back to a default theme like Twenty Seventeen and disable all plugins except for WooCommerce to see if this resolves the issue.If so, then re-enable each one at a time until you find the one that’s causing the conflict.Plugin SupportLuminus Alabi a11n (@luminus)Automattic Happiness Engineer2 years, 11 months ago@steveo123,We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.yawbii (@yawbii)2 years, 6 months agoHi I just restored my old backup website to a new WordPress site and everything is working fine except order is not working. When I test order I keep getting UNABLE TO CREATE ORDER.
    How do I fix it?
    http://www.m6network.com is the the websitejohnpaulbyrne (@johnpaulbyrne)2 years, 5 months agoThought I would share the love and post the real solution to this problem.
    The problem manifests when WooCommerce attempts to save the shop_order post type to wp_posts table.
    When someone hits checkout, the woo data store attempts to save the order as a post:/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php
    at public function create( &$order ) { line 56This is the code that inserts the order:
    $id = wp_insert_post(
    apply_filters(
    ‘woocommerce_new_order_data’,
    array(
    ‘post_date’ => gmdate( ‘Y-m-d H:i:s’, $order->get_date_created( ‘edit’ )->getOffsetTimestamp() ),
    ‘post_date_gmt’ => gmdate( ‘Y-m-d H:i:s’, $order->get_date_created( ‘edit’ )->getTimestamp() ),
    ‘post_type’ => $order->get_type( ‘edit’ ),
    ‘post_status’ => ‘wc-‘ . ( $order->get_status( ‘edit’ ) ? $order->get_status( ‘edit’ ) : apply_filters( ‘woocommerce_default_order_status’, ‘pending’ ) ),
    ‘ping_status’ => ‘closed’,
    ‘post_author’ => 1,
    ‘post_title’ => $this->get_post_title(),
    ‘post_password’ => wc_generate_order_key(),
    ‘post_parent’ => $order->get_parent_id( ‘edit’ ),
    ‘post_excerpt’ => $this->get_post_excerpt( $order ),
    )
    ), true
    );Now you will notice that the insert creates a value in post_password field using wc_generate_order_key()
    If you look in your database you will notice that the post_password table is a varchar with max length of 20 chars. I found that wc_generate_order_key() was generating a password LONGER than 20 chars and therefore the insert was failing which manifests further up the chain as “Unable to create order”Internally wc_generate_order_key() does this:
    function wc_generate_order_key() {
    return ‘wc_’ . apply_filters( ‘woocommerce_generate_order_key’, ‘order_’ . wp_generate_password( 13, false ) );
    }if you notice that wp_generate_password’s first parameter is the length of the password which in this case is 13
    the password is concatenated with “wc_” (length 3) and “order_” (length 6) so 13+3+6 = 22 chars of lengthSo this got me thinking why would Woo write this code?
    Well it turns out that my wordpress version on the affected site was 4.7.12 ( we had ignored the updates to v5 as it as a heavy production site and we hadnt yet tested Gutenberg)
    I checked another site that was already at v5 of wordpress and sure enough the post_password field in wp_posts table is varchar(255) so later version of wordpress > 4.7.12 must have increased this field length:So the solution is:
    1. Update to latest WP version
    2. If you can update to latest WP Version because you havent tested it yet then go into PhpMyAdmin for your MySql database. You can find your Database name from wp-config.php
    Click on wp_posts or whatever prefix your posts table is using and click on “Structure” tab and modify the length of the post_password field to varchar(255)This drove me crazy and I see no solution anywhere on the internet for this.
    Hope this helps someone have a more productive day than I did lol
    ? ?jorgerueda (@jorgerueda)2 years, 5 months agoThanks a lot!!! I don’t know what went wrong when I updated to WP 5, but thanks to you I just corrected the problem. THANKS THANKS a thousend times! I just used phpmyadmin to change the post_password field in wp_posts table as varchar(255) I would have taken me many hours to find outtecladigital (@tecladigital)2 years, 4 months agoThank you johnpaulbyrne2 months ago I had this problem in one of my client’s site. I lose some days of work and at the end I had to rebuild all site.Now I had this problem in another site, and in 5 minutes off “Googling”, I found your message here. And I took just one more minute to solve that bug.Thank you very much for sharing your solution. You save my day ?rukhsar01 (@rukhsar01)2 years, 4 months agoI am facing the same issue with my website from last 5-6 days. I came across this page and did the thing but in my database the post_password is already set to varchar(255).
    Please help me in resolving this issue.jesperj (@jesperj)2 years, 3 months agoI’m having the same issue and I’m running the latest WP so I would assume that the lenght is sufficient. It all started some days ago and I can’t fix it. Store is not functioning as it should.I’m getting a red feild at the top saying “Cant place order” when I try to call on my payment service and finalize the order. Very frustrating.jesperj (@jesperj)2 years, 3 months agoSo I had the online service look into the database and the field was not uppdated. They did that change and now it works fine.One thousand thanks for the heads up!chodos (@chodos)2 years, 1 month agoThank you @johnpaulbyrne
    It worked for me too!

Viewing 13 replies – 1 through 13 (of 13 total)

  • The topic ‘Unable to create order’ is closed to new replies.

Views

CODE IS POETRY.