Use WooCommerce's database prefi
Fixes woocommerce/woocommerce-admin#437
This commit is contained in:
parent
da4a2813b8
commit
76d5417e2b
|
@ -191,7 +191,7 @@ class WC_Admin_Api_Init {
|
||||||
}
|
}
|
||||||
foreach ( $order->get_items() as $order_item ) {
|
foreach ( $order->get_items() as $order_item ) {
|
||||||
$wpdb->replace(
|
$wpdb->replace(
|
||||||
$wpdb->prefix . 'wc_admin_order_product_lookup',
|
$wpdb->prefix . 'wc_order_product_lookup',
|
||||||
array(
|
array(
|
||||||
'order_item_id' => $order_item->get_id(),
|
'order_item_id' => $order_item->get_id(),
|
||||||
'order_id' => $order->get_id(),
|
'order_id' => $order->get_id(),
|
||||||
|
@ -256,8 +256,8 @@ class WC_Admin_Api_Init {
|
||||||
$wc_tables,
|
$wc_tables,
|
||||||
array(
|
array(
|
||||||
// TODO: will this work on multisite?
|
// TODO: will this work on multisite?
|
||||||
"{$wpdb->prefix}wc_admin_order_stats",
|
"{$wpdb->prefix}wc_order_stats",
|
||||||
"{$wpdb->prefix}wc_admin_order_product_lookup",
|
"{$wpdb->prefix}wc_order_product_lookup",
|
||||||
"{$wpdb->prefix}wc_order_tax_lookup",
|
"{$wpdb->prefix}wc_order_tax_lookup",
|
||||||
"{$wpdb->prefix}wc_order_coupon_lookup",
|
"{$wpdb->prefix}wc_order_coupon_lookup",
|
||||||
)
|
)
|
||||||
|
@ -277,7 +277,7 @@ class WC_Admin_Api_Init {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tables = "
|
$tables = "
|
||||||
CREATE TABLE {$wpdb->prefix}wc_admin_order_stats (
|
CREATE TABLE {$wpdb->prefix}wc_order_stats (
|
||||||
order_id bigint(20) unsigned NOT NULL,
|
order_id bigint(20) unsigned NOT NULL,
|
||||||
date_created timestamp DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
date_created timestamp DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||||
num_items_sold int(11) UNSIGNED DEFAULT 0 NOT NULL,
|
num_items_sold int(11) UNSIGNED DEFAULT 0 NOT NULL,
|
||||||
|
@ -290,7 +290,7 @@ class WC_Admin_Api_Init {
|
||||||
PRIMARY KEY (order_id),
|
PRIMARY KEY (order_id),
|
||||||
KEY date_created (date_created)
|
KEY date_created (date_created)
|
||||||
) $collate;
|
) $collate;
|
||||||
CREATE TABLE {$wpdb->prefix}wc_admin_order_product_lookup (
|
CREATE TABLE {$wpdb->prefix}wc_order_product_lookup (
|
||||||
order_item_id BIGINT UNSIGNED NOT NULL,
|
order_item_id BIGINT UNSIGNED NOT NULL,
|
||||||
order_id BIGINT UNSIGNED NOT NULL,
|
order_id BIGINT UNSIGNED NOT NULL,
|
||||||
product_id BIGINT UNSIGNED NOT NULL,
|
product_id BIGINT UNSIGNED NOT NULL,
|
||||||
|
|
|
@ -19,7 +19,7 @@ class WC_Admin_Reports_Categories_Data_Store extends WC_Admin_Reports_Data_Store
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const TABLE_NAME = 'wc_admin_order_product_lookup';
|
const TABLE_NAME = 'wc_order_product_lookup';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order by setting used for sorting categories data.
|
* Order by setting used for sorting categories data.
|
||||||
|
|
|
@ -23,12 +23,12 @@ class WC_Admin_Reports_Orders_Data_Store extends WC_Admin_Reports_Data_Store imp
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const TABLE_NAME = 'wc_admin_order_stats';
|
const TABLE_NAME = 'wc_order_stats';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cron event name.
|
* Cron event name.
|
||||||
*/
|
*/
|
||||||
const CRON_EVENT = 'wc_admin_order_stats_update';
|
const CRON_EVENT = 'wc_order_stats_update';
|
||||||
|
|
||||||
protected $column_types = array(
|
protected $column_types = array(
|
||||||
'orders_count' => 'intval',
|
'orders_count' => 'intval',
|
||||||
|
@ -170,11 +170,11 @@ class WC_Admin_Reports_Orders_Data_Store extends WC_Admin_Reports_Data_Store imp
|
||||||
|
|
||||||
$where_clause .= " AND {$orders_stats_table}.order_id IN (
|
$where_clause .= " AND {$orders_stats_table}.order_id IN (
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT {$wpdb->prefix}wc_admin_order_product_lookup.order_id
|
DISTINCT {$wpdb->prefix}wc_order_product_lookup.order_id
|
||||||
FROM
|
FROM
|
||||||
{$wpdb->prefix}wc_admin_order_product_lookup
|
{$wpdb->prefix}wc_order_product_lookup
|
||||||
WHERE
|
WHERE
|
||||||
{$wpdb->prefix}wc_admin_order_product_lookup.product_id IN ({$allowed_products_str})
|
{$wpdb->prefix}wc_order_product_lookup.product_id IN ({$allowed_products_str})
|
||||||
)";
|
)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class WC_Admin_Reports_Products_Data_Store extends WC_Admin_Reports_Data_Store i
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const TABLE_NAME = 'wc_admin_order_product_lookup';
|
const TABLE_NAME = 'wc_order_product_lookup';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping columns to data type to return correct response types.
|
* Mapping columns to data type to return correct response types.
|
||||||
|
|
|
@ -17,7 +17,7 @@ function wc_admin_order_product_lookup_entry( $order_id ) {
|
||||||
|
|
||||||
foreach ( $order->get_items() as $order_item ) {
|
foreach ( $order->get_items() as $order_item ) {
|
||||||
$wpdb->replace(
|
$wpdb->replace(
|
||||||
$wpdb->prefix . 'wc_admin_order_product_lookup',
|
$wpdb->prefix . 'wc_order_product_lookup',
|
||||||
array(
|
array(
|
||||||
'order_item_id' => $order_item->get_id(),
|
'order_item_id' => $order_item->get_id(),
|
||||||
'order_id' => $order->get_id(),
|
'order_id' => $order->get_id(),
|
||||||
|
|
Loading…
Reference in New Issue