Title: MaxAuray's Replies | WordPress.org

---

# MaxAuray

  [  ](https://wordpress.org/support/users/maxauray/)

 *   [Profile](https://wordpress.org/support/users/maxauray/)
 *   [Topics Started](https://wordpress.org/support/users/maxauray/topics/)
 *   [Replies Created](https://wordpress.org/support/users/maxauray/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/maxauray/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/maxauray/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/maxauray/engagements/)
 *   [Favorites](https://wordpress.org/support/users/maxauray/favorites/)

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] WordPress database error Unknown column ‘wp_wc_order_stats.total_sales’](https://wordpress.org/support/topic/wordpress-database-error-unknown-column-wp_wc_order_stats-total_sales/)
 *  Thread Starter [MaxAuray](https://wordpress.org/support/users/maxauray/)
 * (@maxauray)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-unknown-column-wp_wc_order_stats-total_sales/#post-15907797)
 * Hey Con,
 * Here the syntax to update the database. Please note with MySQL datetime fields
   cannot be before 1000-01-01. Simply updating the table `wp_wc_order_stats` to
   add `total_sales` cannot be achieved until default values are fixed.
 * Thus, to perform this update, here is the SQL command to both fix default datetime
   value and add the missing column.
 *     ```
       ALTER TABLE wp_wc_order_stats
       ALTER COLUMN date_created SET DEFAULT '1000-01-01',
       ALTER COLUMN date_created_gmt SET DEFAULT '1000-01-01',
       ADD   COLUMN total_sales double NOT NULL DEFAULT 0 AFTER num_items_sold;
       ```
   
 * When done, the table should look like bellow:
 *     ```
       +--------------------+-----------------+------+-----+---------------------+-------+
       | Field              | Type            | Null | Key | Default             | Extra |
       +--------------------+-----------------+------+-----+---------------------+-------+
       | order_id           | bigint unsigned | NO   | PRI | NULL                |       |
       | parent_id          | bigint unsigned | NO   |     | 0                   |       |
       | date_created       | datetime        | NO   | MUL | 1000-01-01 00:00:00 |       |
       | date_created_gmt   | datetime        | NO   |     | 1000-01-01 00:00:00 |       |
       | num_items_sold     | int             | NO   |     | 0                   |       |
       | total_sales        | double          | NO   |     | 0                   |       |
       | tax_total          | double          | NO   |     | 0                   |       |
       | shipping_total     | double          | NO   |     | 0                   |       |
       | net_total          | double          | NO   |     | 0                   |       |
       | returning_customer | tinyint(1)      | YES  |     | NULL                |       |
       | status             | varchar(200)    | NO   | MUL | NULL                |       |
       | customer_id        | bigint unsigned | NO   | MUL | NULL                |       |
       +--------------------+-----------------+------+-----+---------------------+-------+
       ```
   
 * Thanks for your help. Warmest,
 * —
    Maxime.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] WordPress database error Unknown column ‘wp_wc_order_stats.total_sales’](https://wordpress.org/support/topic/wordpress-database-error-unknown-column-wp_wc_order_stats-total_sales/)
 *  Thread Starter [MaxAuray](https://wordpress.org/support/users/maxauray/)
 * (@maxauray)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-unknown-column-wp_wc_order_stats-total_sales/#post-15906915)
 * Hey Mirko.
 * Thanks for your reply.
 * Uninstalling and reinstalling the plug-in is not an acceptable option: this issue
   occurs on a production server. But this issue is not blocking: ordering process
   works optimally and we do not rely on WooCommerce plugin for sales analytics.
   I would just like not to have these unnecessary warnings in the server logs.
 * Could you, please, provide instructions to create this missing columns (or at
   least the column type, its default value, etc., I am at ease with SQL) and to
   populate it from data already existing in the data (we have order data up to 
   2019 in it).
 * Warmest,
 * —
    Maxime.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] WordPress database error Unknown column ‘wp_wc_order_stats.total_sales’](https://wordpress.org/support/topic/wordpress-database-error-unknown-column-wp_wc_order_stats-total_sales/)
 *  Thread Starter [MaxAuray](https://wordpress.org/support/users/maxauray/)
 * (@maxauray)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-unknown-column-wp_wc_order_stats-total_sales/#post-15904554)
 * Hello,
 * Here are the columns in the table.
 *     ```
       mysql> show columns from wp_wc_order_stats;
       +--------------------+-----------------+------+-----+---------------------+-------+
       | Field              | Type            | Null | Key | Default             | Extra |
       +--------------------+-----------------+------+-----+---------------------+-------+
       | order_id           | bigint unsigned | NO   | PRI | NULL                |       |
       | parent_id          | bigint unsigned | NO   |     | 0                   |       |
       | date_created       | datetime        | NO   | MUL | 0000-00-00 00:00:00 |       |
       | date_created_gmt   | datetime        | NO   |     | 0000-00-00 00:00:00 |       |
       | num_items_sold     | int             | NO   |     | 0                   |       |
       | tax_total          | double          | NO   |     | 0                   |       |
       | shipping_total     | double          | NO   |     | 0                   |       |
       | net_total          | double          | NO   |     | 0                   |       |
       | returning_customer | tinyint(1)      | YES  |     | NULL                |       |
       | status             | varchar(200)    | NO   | MUL | NULL                |       |
       | customer_id        | bigint unsigned | NO   | MUL | NULL                |       |
       +--------------------+-----------------+------+-----+---------------------+-------+
       11 rows in set (0.00 sec)
       ```
   
 * Answer is: I do not have the column total_sales in the table wp_wc_order_stats
   present.
 * Questions are:
    – why is this column missing as WooCommerce database was updated
   by the plugin itself? – how to fix this manually (statement to create the column
   + statement to populate the new column with past orders)?
 * Thanks.
 * —
    Maxime.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Giftable for WooCommerce] Customize template](https://wordpress.org/support/topic/customize-template-9/)
 *  Thread Starter [MaxAuray](https://wordpress.org/support/users/maxauray/)
 * (@maxauray)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/customize-template-9/#post-11875052)
 * I think I will turn to another plugin, instead.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Giftable for WooCommerce] Call to a member function get_type() on null](https://wordpress.org/support/topic/call-to-a-member-function-get_type-on-null/)
 *  Thread Starter [MaxAuray](https://wordpress.org/support/users/maxauray/)
 * (@maxauray)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/call-to-a-member-function-get_type-on-null/#post-11866921)
 * Hi [@decomteam](https://wordpress.org/support/users/decomteam/).
 * I am working on a custom theme, nothing to do with WooCommerce theme files, except
   it rigorously respect WordPress coding rules.
 * As part of it, the get_image method of WP_Product is called with parameters for
   my own needs. See [https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#1825-1849](https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#1825-1849)
 * In my code:
    `$product->get_image( 'full', array( 'class' => 'block package checkout'))`
 * But that’s not the point. The point applies to the `woocommerce_cart_item_thumbnail`
   filter that cascades to a call to `DGFW_Public->gift_cart_thumbnail` as defined
   in .\public\Public.php.
 * There, in Public.php:488, a call to method `DGFW_Public->is_gift($cart_item['
   data'])` occurs **without verifying if the ‘data’ entry of `$cart_item` contains
   an object**. Then `DGFW->is_gift($product)` with $product = $cart_item[‘data’]
   calls the `get_type()` method on $product whatever $product is. In my case, it
   may be NULL. Fatal Error.
 * Please change the Public.php:488 from:
 * `if ($cart_item && $cart_item['variation_id'] && $this->is_gift($cart_item['data'])){`
 * to
 * `if ($cart_item && $cart_item['variation_id'] && is_object($cart_item['data'])&&
   $this->is_gift($cart_item['data']) ) {`
    -  This reply was modified 7 years, 1 month ago by [MaxAuray](https://wordpress.org/support/users/maxauray/).
    -  This reply was modified 7 years, 1 month ago by [MaxAuray](https://wordpress.org/support/users/maxauray/).

Viewing 5 replies - 1 through 5 (of 5 total)