• Resolved tendenzeshabbychic

    (@tendenzeshabbychic)


    Hi everyone,
    I’m trying to add a custom column to the WooCommerce Orders page that displays the total number of orders made by each customer based on their billing email address. Before switching to HPOS (High-Performance Order Storage), the code worked perfectly, and the custom column was displayed correctly. However, after enabling HPOS, the column is no longer visible in the Orders table, nor does it appear in the Screen Options.

    ` WordPress Environment

    WordPress address (URL):
    Site address (URL):
    WC Version: 9.3.3
    Legacy REST API Package Version: Il plugin API REST legacy non è installato in questo sito.
    Action Scheduler Version: ? 3.8.2
    Log Directory Writable: ?
    WP Version: 6.6.2
    WP Multisite: –
    WP Memory Limit: 512 MB
    WP Debug Mode: ?
    WP Cron: –
    Language: it_IT
    External object cache: ? Server Environment

    Code Used:

    Below is the code I’m using to add the custom column. It should display the label “Total Orders (Email)” in the Orders table:

    add_filter( 'manage_edit-shop_order_columns', 'ecommercehints_add_order_count_column', 20 );
    function ecommercehints_add_order_count_column( $columns ) {
    $columns['email_order_count'] = __( 'Totale Ordini (Email)', 'woocommerce' );
    return $columns;
    }

    // Populate column with order count
    add_action( 'manage_shop_order_posts_custom_column', 'ecommercehints_populate_new_column' );
    function ecommercehints_populate_new_column( $column ) {
    global $post;
    if ( 'email_order_count' === $column ) {
    $billing_email = get_post_meta( $post->ID, '_billing_email', true );
    if ( $billing_email ) {
    $customer_orders = get_posts( array(
    'numberposts' => -1,
    'meta_key' => '_billing_email',
    'meta_value' => $billing_email,
    'post_type' => wc_get_order_types(),
    'post_status' => array_keys( wc_get_order_statuses() ),
    ) );
    $order_count = count( $customer_orders );
    echo $order_count;
    }
    }
    }

    Problem Description:

    1. The column does not appear in the WooCommerce Orders table.
    2. The column is not visible under the Screen Options to enable/disable it.
    3. Before switching to HPOS, the column was displaying correctly with the same code.
    4. I tried enabling WordPress debugging (WP_DEBUG, WP_DEBUG_LOG), but no logs are generated, which suggests the hook might not be firing.
Viewing 1 replies (of 1 total)
  • Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello tendenzeshabbychic,

    Thank you for contacting WooCommerce support.

    With the introduction of HPOS (High-Performance Order Storage), WooCommerce stores order data differently compared to the legacy system. This change likely means that your custom code is no longer compatible with HPOS, which is why the custom column isn’t appearing in the Orders table or Screen Options.

    Since custom code is beyond the scope of support, I recommend consulting with a WooCommerce developer to adjust your code for HPOS compatibility. You can find experienced developers through platforms like Codeable or WooExperts.

    Please don’t hesitate to contact us again if you have more questions or concerns.
    We are here to help ??

    Best regards.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.