Add defination of order meta data table.

Made table name methods static so that they can be reused.
This commit is contained in:
vedanshujain 2022-03-24 13:45:31 +05:30
parent ee834e2cf1
commit aa00d7af68
1 changed files with 24 additions and 4 deletions

View File

@ -17,7 +17,7 @@ class OrdersTableDataStore extends \Abstract_WC_Order_Data_Store_CPT implements
*
* @return string The custom orders table name.
*/
public function get_orders_table_name() {
public static function get_orders_table_name() {
global $wpdb;
return $wpdb->prefix . 'wc_orders';
}
@ -27,7 +27,7 @@ class OrdersTableDataStore extends \Abstract_WC_Order_Data_Store_CPT implements
*
* @return string The order addresses table name.
*/
public function get_addresses_table_name() {
public static function get_addresses_table_name() {
global $wpdb;
return $wpdb->prefix . 'wc_order_addresses';
}
@ -37,11 +37,21 @@ class OrdersTableDataStore extends \Abstract_WC_Order_Data_Store_CPT implements
*
* @return string The orders operational data table name.
*/
public function get_operational_data_table_name() {
public static function get_operational_data_table_name() {
global $wpdb;
return $wpdb->prefix . 'wc_order_operational_data';
}
/**
* Get the orders meta data table name.
*
* @return string Name of order meta data table.
*/
public static function get_meta_table_name() {
global $wpdb;
return $wpdb->prefix . 'wc_ordes_meta';
}
/**
* Get the names of all the tables involved in the custom orders table feature.
*
@ -185,6 +195,7 @@ class OrdersTableDataStore extends \Abstract_WC_Order_Data_Store_CPT implements
$orders_table_name = $this->get_orders_table_name();
$addresses_table_name = $this->get_addresses_table_name();
$operational_data_table_name = $this->get_operational_data_table_name();
$meta_table = $this->get_meta_table_name();
$sql = "
CREATE TABLE $orders_table_name (
@ -247,7 +258,16 @@ CREATE TABLE $operational_data_table_name (
discount_total_amount decimal(26, 8) NULL,
KEY order_id (order_id),
KEY order_key (order_key)
);";
);
CREATE TABLE $meta_table (
id bigint(20) unsigned auto_increment primary key,
order_id bigint(20) unsigned null,
meta_key varchar(255),
meta_value text null,
KEY meta_key_value (meta_key, meta_value(100))
);
";
return $sql;
}
}