0

Whenever I have made a website with Wordpress, the Woocommerce orders are saved as a post. I have several websites where the Woocommerce order page has this url:

https://domain.com/wp-admin/edit.php?post_type=shop_order

And each order has a url like this:

https://domain.com/wp-admin/post.php?post=31056&action=edit

But on the last website I made, the Woocommerce orders, instead of being posts, are pages and their url is this:

https://domain.com/wp-admin/admin.php?page=wc-orders

And each order has a url like this:

https://domain.com/wp-admin/admin.php?page=wc-orders&action=edit&id=3463

I have not configured this website differently, I do not have plugins that change that configuration.

There is a plugin that requires Woocommerce orders to be posts and not pages. How can I change that configuration without using plugins?

I know it must be some configuration but it has never happened to me before.

Thank you

2
  • You'll have to ask the plugin's support team about this. Third-party plugin support is off topic here.
    – Pat J
    Dec 27, 2023 at 18:10
  • WooCommerce changed how orders are stored: woo.com/document/high-performance-order-storage If a plugin isn’t working you’ll need to run it in a compatibility mode. That article has mor information. Dec 27, 2023 at 18:28

2 Answers 2

1

To change the WooCommerce order pages back to posts without using a plugin, you can modify the post type of WooCommerce orders in WordPress. This can be achieved by adding custom code to your theme's functions.php file or creating a custom plugin. Here are the steps to do this:

  1. Access Your WordPress Files: You can access your WordPress files through an FTP client or a file manager provided by your hosting provider.
  2. Locate the Theme's functions.php File: If you want to add the code to your theme, navigate to your WordPress theme's directory, usually located at wp-content/themes/your-theme-name/.
  3. Edit functions.php: Open the functions.php file for editing. You can use a code editor or a plain text editor.
  4. Add the Following Code to functions.php:
/**
 * Change WooCommerce order post type to 'post'.
 */
function change_woocommerce_order_post_type() {
    global $wpdb;

    // Define the new post type (in this case, 'post').
    $new_post_type = 'post';

    // Define the old post type (WooCommerce order post type, which is 'shop_order').
    $old_post_type = 'shop_order';

    // Update the post type in the database.
    $wpdb->query(
        $wpdb->prepare(
            "UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s",
            $new_post_type,
            $old_post_type
        )
    );
}

// Hook the function to run during the 'init' action.
add_action('init', 'change_woocommerce_order_post_type');
  1. Save the File: After adding the code, save the functions.php file.

  2. Clear WordPress Cache: If you have a caching plugin installed, make sure to clear the cache.

  3. Test: Now, when you go to your WooCommerce orders page, you should see that orders are displayed as posts rather than pages.

This code hooks into the WordPress init action and updates the post type for WooCommerce orders in the database from 'shop_order' to 'post'. It effectively changes the orders from being treated as pages to being treated as regular posts.

Make sure to backup your site before making any code changes, and be cautious when editing theme files or adding custom code.

1
  • Excellent snippet, I'll leave it saved
    – OCHOA
    Dec 28, 2023 at 11:12
0

Thank you all, in the end it is super easy, I was checking the configurations of my other websites a lot and everything was in one configuration.

In

Woocommerce > Settings > Advanced > Features >

It is defined how the orders will be saved and if they already exist they can be easily migrated.

Apparently (according to the config) it is high performance to save them as pages instead of posts.

Thank you all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.