Ecommerce Shopify WordPress Discussion

Modify original WC_Order query in order page – Woocommerce

I need to enable sorting features in /my-account/orders page. Is there any way to modify the original WC_Order query or where is the actual query located in woocommerce? Screenshot I have modified the html as you can check in screenshot. I need to push the order and orderby key to the original WC_Order query.
The way to modify any query is to use the pre_get_posts hook. Inside the callback function, you add conditionals so that it only runs where you want and on the query you want. So you'll add this to functions.php or your plugin: function palit_modify_order_list_query( $query ){ if ( is_page( 'orders' ) && $query->get('post_type') == 'shop_order' ) { $query->set( 'order', 'ASC' ); $query->set( 'orderby', 'meta_value_num' ); $query->set( 'meta_key', 'your_meta_value_key' ); } } add_action( 'pre_get_posts', 'palit_modify_order_list_query' );

January 20, 2024

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.