Ecommerce Shopify WordPress Discussion

Woocommerce HPOS is not fetching the custom column values in order list

I have enabled the new WooCommerce High-Performance Order Storage (HPOS), and it uses different filters and actions hooks when I want to add a custom column to the WooCommerce Admin order list. Based on Custom column with order metadata in WooCommerce HPOS admin orders list answer to my previous question, Here is my current code that uses those new filter and action hooks: add_filter('manage_woocommerce_page_wc-orders_columns', array($this, 'source_medium_column')); add_action('manage_woocommerce_page_wc-orders_custom_column', array($this, 'source_medium_value_wc_orders'), 10, 2); The filter hook is working fine, adding the column, but when I fetch the values for the column it just retrieves the values for the order on the top. The code for it is: public function source_medium_value_wc_orders($column, $order) { if ($column === 'analytify_source') { // Check for the new meta key first $source = $order->get_meta('analytify_woo_order_source'); if ($source) { echo $source; return; } // If the new meta key is not found, try the deprecated one $source_medium_deprecated = $order->get_meta('analytify_woo_single_source'); if ($source_medium_deprecated) { echo $source_medium_deprecated; return; } // Fetch source/medium on request. if (!$source && isset($_GET['analytify_woo_fetch_sale_source'])) { error_log('Fetching source/medium for order ' . $order->get_id()); $date_created = $order->get_date_created()->format('Y-m-d'); $start_date = date('Y-m-d', strtotime($date_created . ' - 5 days')); $end_date = date('Y-m-d', strtotime($date_created . ' + 5 days')); // Get sources from ga4. if (method_exists('WPANALYTIFY_Utils', 'get_ga_mode') && 'ga4' === WPANALYTIFY_Utils::get_ga_mode()) { $stats = $GLOBALS['WP_ANALYTIFY']->get_reports( 'analytify_woo_order_source', array(), array( 'start' => $start_date, 'end' => $end_date ), array( 'sourceMedium', 'transactionId', ), array(), array( 'logic' => 'AND', 'filters' => array( array( 'type' => 'dimension', 'name' => 'transactionId', 'match_type' => 1, 'value' => $order->get_id() ) ) ), 0, false ); error_log('Stats: ' . print_r($stats, true)); if (!empty($stats['rows'][0]['sourceMedium'])) { $source = $stats['rows'][0]['sourceMedium']; $order->update_meta_data('analytify_woo_order_source', $source); $order->save(); } } else { $stats = $GLOBALS['WP_ANALYTIFY']->pa_get_analytics_dashboard('ga:totalEvents', $start_date, $end_date, 'ga:sourceMedium,ga:eventCategory,ga:eventLabel', false, 'ga:eventCategory==analytify_orders;ga:eventAction==order_created;ga:eventLabel==' . $order->get_id()); if (isset($stats['rows'][0][0])) { $source = $stats['rows'][0][0]; $order->update_meta_data('analytify_woo_order_source', $source); $order->save(); } } } error_log('Final source: ' . $source); echo $source; } } My question here is that whether I have to loop through the orders in order to get the id for all the order as when I hard coded the value of first order in the code all the source medium are fetched but as I use some other order Id same no source / medium is fetched. There is a separated button too that we use to fetch the source/medium but in it too the same thing as mentioned above happens. The code for the button is public function show_source_fect_button($which) { global $post_type; $screen = get_current_screen(); if ($post_type === 'shop_order' && 'top' === $which) { echo '<input style="background: #fff url(' . ANALYTIFY_PLUGIN_URL . 'assets/img/analytify-logo-small.svg' . ') no-repeat left 10px center; padding-left: 35px;" type="submit" class="analytify_woo_fetch_sale_source button-secondary" value="Fetch Traffic Sources" name="analytify_woo_fetch_sale_source" style="margin-top:3px">'; } elseif ('woocommerce_page_wc-orders' === $screen->id) { echo '<input style="background: #fff url(' . ANALYTIFY_PLUGIN_URL . 'assets/img/analytify-logo-small.svg' . ') no-repeat left 10px center; padding-left: 35px;" type="submit" class="analytify_woo_fetch_sale_source button-secondary" value="Fetch Traffic Sources" name="analytify_woo_fetch_sale_source" style="margin-top:3px">'; } }
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.