Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter MaxAuray

    (@maxauray)

    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.

    Thread Starter MaxAuray

    (@maxauray)

    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.

    Thread Starter MaxAuray

    (@maxauray)

    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.

    Thread Starter MaxAuray

    (@maxauray)

    I think I will turn to another plugin, instead.

    Thread Starter MaxAuray

    (@maxauray)

    Hi @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

    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 5 years, 6 months ago by MaxAuray.
    • This reply was modified 5 years, 6 months ago by MaxAuray.
Viewing 5 replies - 1 through 5 (of 5 total)