SQL woocommerce 在哪里存储订单?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31746307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 03:52:41  来源:igfitidea点击:

where does woocommerce store orders?

sqldatabasewordpresswoocommerce

提问by Ke.

I'm looking in the sql db and I can see something that resembles orders inside wp_posts . However, I would expect them to be inside the tables beginning with wp_woocommerce.

我正在查看 sql 数据库,我可以看到类似于 wp_posts 中的订单的东西。但是,我希望它们在以 wp_woocommerce 开头的表格中。

Can anyone shed some light on this phenomenon?

任何人都可以对这种现象有所了解吗?

Cheers

干杯

采纳答案by Hymans

In woocommerce orders are modelled as a custom post typeso they are stored in wp_postsas you found. See WooCommerce taxonomies and post typesfor a list of the custom post types that woocommerce uses. Orders are stored as the type shop_order

在 woocommerce 中,订单被建模为自定义帖子类型,因此它们会wp_posts按您找到的方式存储。有关woocommerce 使用的自定义帖子类型列表,请参阅WooCommerce 分类法和帖子类型。订单存储为类型shop_order

Separate items within an Order are stored as separate records in the custom table woocommerce_order_items

订单中的单独项目在自定义表woocommerce_order_items中存储为单独的记录

回答by Matt Merrill

Updated plug-in version information 8/10/2018

更新插件版本信息 8/10/2018

Orders are a custom post type. From WooCommerce Post Types:

订单是自定义帖子类型。从 WooCommerce帖子类型

  • Shop Order (shop_order)
  • 商店订单 (shop_order)

Orders live in the wp_poststable (post_type = 'shop_order'). More data is available by looking up the order's post_id in the wp_postmetatable.

订单存在于wp_posts表 ( post_type = 'shop_order') 中。通过在wp_postmeta表中查找订单的 post_id 可以获得更多数据。

In addition, from the WooCommerce GitHub Wiki Database Description

另外,来自 WooCommerce GitHub Wiki数据库描述

  • woocommerce_order_items– Stores line items which are associated with orders.
  • woocommerce_order_itemmeta– Stores meta data about order line items.
  • woocommerce_order_items– 存储与订单关联的行项目。
  • woocommerce_order_itemmeta– 存储有关订单行项目的元数据。

Currently the WordPress WooCommerce plug-in version is 3.4.x

目前WordPress WooCommerce插件版本为3.4.x

回答by Aamer Shahzad

WooCommerce orders are "custom post" they are stored in "wp_posts" under "post_type" -> ""shop_order"

WooCommerce 订单是“自定义帖子”,它们存储在“post_type”->“”shop_order”下的“wp_posts”中

if you want to select shop orders with sql query you can do something like below.

如果您想使用 sql 查询选择商店订单,您可以执行以下操作。

global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'shop_order'", ARRAY_A );

回答by csandreas1

You can find them inside wp_poststable.

您可以在wp_posts表中找到它们。

In PhpMyAdmin:

在 PHPMyAdmin 中:

Click wp_poststable, then click SQL Tab and run the following query, assuming wp_posts is your table name:

单击wp_posts表,然后单击 SQL 选项卡并运行以下查询,假设 wp_posts 是您的表名:

Select * from wp_posts where post_type='shop_order'

Select * from wp_posts where post_type='shop_order'

Then you have all the data regarding woocommerce orders

然后你就拥有了关于 woocommerce 订单的所有数据

click "Show all" checkbox

单击“全部显示”复选框

Search for "completed" for completed orders

为已完成的订单搜索“已完成”

回答by user918475

I recently restored the orders data manually and here is the table I found.

我最近手动恢复了订单数据,这是我找到的表格。

wp_posts //post_type = shop_order
wp_postmeta 
wp_woocommerce_order_items
wp_woocommerce_order_itemmeta

Make sure your order_id/order_item_id reference is correct on postmeta and itemmeta.

确保您的 order_id/order_item_id 参考在 postmeta 和 itemmeta 上是正确的。

回答by Dylan Wijnen

wp_woocommerce_order_itemmeta
wp_woocommerce_order_items
wp_posts

Depending on the kind of data your looking for you have to look in diffrent places. If you have PHPMyAdmin try and find the data your looking for.

根据您要查找的数据类型,您必须在不同的地方查找。如果您有 PHPMyAdmin,请尝试查找您要查找的数据。