• Resolved Cezar Ayran

    (@ayrancd)


    I am trying to change the order of the columns in my order page however… nothing seems to work ??

    • Am I supposed to add all columns to this list? I can reorder custom columns between them but not all of them
    function so_58454709_reorder_orders_columns( $columns ) {
        unset( $columns['cEmail'] );
        unset( $columns['oNotes'] );
        unset( $columns['insured'] );
        unset( $columns['cNotes'] );
    
        $new_columns = array(
            'order-status'  => __( 'Status', 'Text Domain' ),
            'order-number'  => __( 'Number', 'Text Domain' ),
            'order-actions' => __( 'Actions', 'Text Domain' ),
            'order-total'   => __( 'Total', 'Text Domain' ),
            'order-date'    => __( 'Date', 'Text Domain' ),
        );
    
        return array_merge( $new_columns, $columns );
    }
    add_filter( 'woocommerce_account_orders_columns', 'so_58454709_reorder_orders_columns' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    It looks like you’re trying to reorder the columns on the WooCommerce “My Account” orders page. However, in WooCommerce, this filter woocommerce_account_orders_columns is used to customize the columns displayed in the customer’s “My Account” orders table. It doesn’t directly affect the order columns in the WooCommerce admin order list.

    To reorder columns in the WooCommerce admin order list, you need to use a different approach. You can use the manage_edit-shop_order_columns filter hook to modify the columns displayed in the admin order list. Here’s an example of how to do this:

    function custom_reorder_admin_order_columns( $columns ) {
        $new_columns = array(
            'order-status'  => __( 'Status', 'Text Domain' ),
            'order-number'  => __( 'Number', 'Text Domain' ),
            'order-actions' => __( 'Actions', 'Text Domain' ),
            'order-total'   => __( 'Total', 'Text Domain' ),
            'order-date'    => __( 'Date', 'Text Domain' ),
        );
    
        // Reorder the columns as desired
        $columns = array_merge( $new_columns, $columns );
    
        // Remove unwanted columns
        unset( $columns['cEmail'] );
        unset( $columns['oNotes'] );
        unset( $columns['insured'] );
        unset( $columns['cNotes'] );
    
        return $columns;
    }
    add_filter( 'manage_edit-shop_order_columns', 'custom_reorder_admin_order_columns' );

    This code snippet reorders the columns in the admin order list as you specified and removes the unwanted columns. Make sure you place this code in your theme’s functions.php file or in a custom plugin.

    After adding this code, you should see the columns reordered as you’ve defined in your function.

    Thread Starter Cezar Ayran

    (@ayrancd)

    @owadud655 that worked well! Thanks a lot, I made a few changes and I’m pasting the code here if someone needs it.

    function wc_reorder_order_columns($columns){
        $new_columns = array(
            'order_number'  => __( 'Order', 'Text Domain' ),
            'order_date'    => __( 'Date', 'Text Domain' ),
            'order_status'  => __( 'Status', 'Text Domain' ),
            'cEmail'  => __( 'Email', 'Text Domain' ),
            'oNotes'  => __( 'Order Notes', 'Text Domain' ),
            'insured'  => __( 'Insured', 'Text Domain' ),
            'cNotes'  => __( 'Customer Notes', 'Text Domain' ),
            'order_total'   => __( 'Total', 'Text Domain' ),
            'wc_actions' => __( 'Actions', 'Text Domain')
        );
        $columns = array_merge( $new_columns, $columns );
        return $columns;
    }
    add_filter( 'manage_edit-shop_order_columns', 'wc_reorder_order_columns' );

    Hi,

    You’re welcome! That’s great to hear it worked well for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Reorder order columns’ is closed to new replies.