Home Forums WoodMart support forum Unable to customize the woocommerce order area on backend

Unable to customize the woocommerce order area on backend

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #547483

    refa
    Participant

    Hi,

    I noticed an issue, when I try to customize the woocommerce -> order area filter from the backend it’s not showing. When I tried with a different theme (storefront theme) it appeared, how to resolve this?

    I attached the screenshots below for your reference.

    Thank you,

    #547594

    I have tested this code on our test site and it is working. Try to add the following code in the function.php of the child theme.

    // Custom function where metakeys / labels pairs are defined
    function get_filter_shop_order_meta( $domain = 'woocommerce' ){
        // Add below the metakey / label pairs to filter orders
        return [
            '_billing_company' => __('Billing company', $domain),
            '_order_total'     => __('Gran total', $domain), 
        ];
    }
    
    // Add a dropdown to filter orders by meta
    add_action( 'restrict_manage_posts', 'display_admin_shop_order_by_meta_filter' );
    function display_admin_shop_order_by_meta_filter(){
        global $pagenow, $typenow;
    
        if( 'shop_order' === $typenow && 'edit.php' === $pagenow ) {
            $domain    = 'woocommerce';
            $filter_id = 'filter_shop_order_by_meta';
            $current   = isset($_GET[$filter_id])? $_GET[$filter_id] : '';
    
            echo '<select name="'.$filter_id.'">
            <option value="">' . __('Filter by meta…', $domain) . '</option>';
    
            $options = get_filter_shop_order_meta( $domain );
    
            foreach ( $options as $key => $label ) {
                printf( '<option value="%s"%s>%s</option>', $key, 
                    $key === $current ? '" selected="selected"' : '', $label );
            }
            echo '</select>';
        }
    }
    
    // Process the filter dropdown for orders by Marketing optin
    add_filter( 'request', 'process_admin_shop_order_marketing_by_meta', 99 );
    function process_admin_shop_order_marketing_by_meta( $vars ) {
        global $pagenow, $typenow;
        
        $filter_id = 'filter_shop_order_by_meta';
    
        if ( $pagenow == 'edit.php' && 'shop_order' === $typenow 
        && isset( $_GET[$filter_id] ) && ! empty($_GET[$filter_id]) ) {
            $vars['meta_key']   = $_GET[$filter_id];
            $vars['orderby']    = 'meta_value';
        }
        return $vars;
    }
    // (Optional) Make a custom meta field searchable from the admin order list search field
    add_filter( 'woocommerce_shop_order_search_fields', 'shop_order_meta_search_fields', 10, 1 );
    function shop_order_meta_search_fields( $meta_keys ){
    foreach ( get_filter_shop_order_meta() as $meta_key => $label ) {
    $meta_keys[] = $meta_key;
    }
    return $meta_keys;
    }
    
    #547843

    refa
    Participant

    I tried still it’s not showing. When I changed the theme it showed.
    Please find the screenshot below for the same.

    • This reply was modified 9 months, 1 week ago by refa.
    #547906

    Hello,

    Can you please share the WP admin login details of your site so I will check and give you a possible solution.

    Best Regards.

    #547922

    refa
    Participant

    Please find the credentials below.
    If you want to deactivate any plugin temporarily to test, please do.
    Please use the child theme for the functions.

    #548078

    Hello,

    Sorry to say but right now we are unable to access your Dashboard due to a critical error.

    Could you please share your Site’s FTP Login details too so that we can further check?

    Best Regards

    #548301

    refa
    Participant

    Due to some reason, I can’t provide FTP credentials. I resolved the critical error can you check now?

    #548425

    Hello,

    I have checked this code with the default woocommerce theme and it is still the same.
    See screenshot for clarification:
    https://ibb.co/bWLjVM4

    Such modification requires complicated code customization which is not covered by our support. All the customizations made in the theme files are at your own risk. Our support doesn’t cover any issues caused by changes in the theme code.

    Best Regards.

    #548735

    refa
    Participant

    I tried it on my testing site, and it’s working fine there. That’s why I asked for the support.
    It’s not working on my live site. I used the same code, I used on the Woodmart child theme only.

    Check the screenshots for your reference.

    If you want to check the testing site, please check I shared the credentials below.

    #548843

    Hello,

    Such modification requires complicated code customization which is not covered by our support. All the customizations made in the theme files are at your own risk. Our support doesn’t cover any issues caused by changes in the theme code.

    You need to find a third party plugin to achieve more functionality that best suits you. We have not tested such kinds of plugins, so we don’t have any detailed suggestions
    https://wordpress.org/plugins/additional-order-filters-for-woocommerce/

    Best Regards.

    #551915

    refa
    Participant

    I tried that plugin but it didn’t work for me.

    The customization I tried on the Woocommerce -> Orders page is not working even if it is a plugin or custom code it doesn’t matter, I don’t know why. I also tried with the below code to add a Time column on the Woocommerce -> Order page that also didn’t work.

    /* Add time column to the woocommerce orders area */

    function custom_shop_order_column_headers($columns)
    {
    $new_columns = array();

    foreach ($columns as $key => $column) {
    $new_columns[$key] = $column;
    if ($key === ‘order_date’) {
    $new_columns[‘order_time’] = __(‘Time’, ‘woocommerce’);
    }
    }

    return $new_columns;
    }
    add_filter(‘manage_edit-shop_order_columns’, ‘custom_shop_order_column_headers’);

    // Display Date and Time in custom column
    function custom_shop_order_column_content($column)
    {
    global $post, $the_order;

    if ($column === ‘order_time’) {
    if (empty($the_order)) {
    $the_order = wc_get_order($post->ID);
    }

    if ($the_order) {
    echo ‘<time datetime=”‘ . esc_attr($the_order->get_date_created()->date(‘c’)) . ‘”>’ . esc_html($the_order->get_date_created()->date(‘H:i’)) . ‘</time>’;
    }
    }
    }
    add_action(‘manage_shop_order_posts_custom_column’, ‘custom_shop_order_column_content’);

    Attachments:
    You must be logged in to view attached files.
    #552060

    Hello,

    Such modification requires complicated code customization which is not covered by our support. All the customizations made in the theme files are at your own risk. Our support doesn’t cover any issues caused by changes in the theme code.

    Best Regards.

    #552197

    refa
    Participant

    You didn’t get about my issue, the issue is not with the code. Even if I install any plugin related to Woocommerce -> Order page on the backend is not work for me. That too on only this site, I have another site with the same woodmart theme there it’s working.

    For example this plugin

    https://wordpress.org/plugins/additional-order-filters-for-woocommerce/

    This plugin or the custom code that I mentioned in my previous message is not working only on this site, on the other site both are working. I am using the same theme and the same set of plugins on both sites.

    I hope you understand about the issue.

    #552207

    refa
    Participant

    Just now I noticed both links/endpoints are different.

    The customization working endpoint is “/wp-admin/edit.php?post_type=shop_order”
    and not working endpoint is “/wp-admin/admin.php?page=wc-orders”

    How to change my endpoint to the working one?

    Please find the attached screenshot for your reference.

    Thank you,

    #552252

    Hello,

    I suggest disable all plugins except these ones:

    Elementor or WPBackary
    Woodmart Core
    WooCommerce
    Enable the Parent theme

    Then activate the plugins one by one, checking the issue to detect which one causes the problem.

    If the issue remains, check how it works with some default WordPress themes like TwentyTwenty or WooCommerce Storefront to understand if it is our theme issue or not because it is related to woocommerce customization.

    Best Regards.

    #552255

    refa
    Participant

    I resolved the issue.

    It’s because of the woocommerce High-performance order storage feature.

    #552343

    Hello,

    You are Most Welcome.

    We are glad that you managed to solve the problem yourself. You are Great!!!

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Topic Closed.
    Best Regards.

Viewing 17 posts - 1 through 17 (of 17 total)

The topic ‘Unable to customize the woocommerce order area on backend’ is closed to new replies.