Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing two issues: 1. WooCommerce analytics reports are not downloading for currencies like USD and Euro, instead, they are being sent via email. 2. There is a speed issue on the admin side due to background queries.
Solution:
For the first issue, it was determined that this behavior aligns with WooCommerce's settings. When there are many order items, WooCommerce is configured to send an email instead of downloading the CSV file directly. This is not an issue with WooCommerce Multilingual or WPML.
For the second issue, we provided a custom code solution to add a 'Direct Export (Browser)' button to the Analytics report page. This button allows for direct downloading of the report without waiting for an email. Here is the code to implement:

function add_custom_export_button() { ?>
    <script type="text/javascript">
        jQuery(document).ready(function($) {
            const interval = setInterval(function() {
                const downloadButton = $('.woocommerce-table__download-button');
                if (downloadButton.length) {
                    const customExportButton = $('<button class="button-primary" style="margin-left: 10px;">Direct Export (Browser)</button>')
                        .on("click", function(e) {
                            e.preventDefault();
                            fetchAndDownloadCSV();
                        });
                    downloadButton.after(customExportButton);
                    clearInterval(interval);
                }
            }, 500);
        });
    </script>
<?php }
add_action('admin_footer', 'add_custom_export_button');
function custom_export_script() { ?>
    <script type="text/javascript">
        async function fetchAndDownloadCSV() {
            try {
                const response = await fetch('<?php echo admin_url('admin-ajax.php?action=custom_order_export'); ?>');
                const data = await response.json();
                if (data && data.orders) {
                    let csvContent = "data:text/csv;charset=utf-8,";
                    const headers = ["Order ID", "Date", "Status", "Total"];
                    csvContent += headers.join(",") + "\r\n";
                    data.orders.forEach(order => {
                        const row = [order.id, order.date, order.status, order.total];
                        csvContent += row.join(",") + "\r\n";
                    });
                    const encodedUri = encodeURI(csvContent);
                    const link = document.createElement("a");
                    link.setAttribute("href", encodedUri);
                    link.setAttribute("download", "orders_export.csv");
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);
                } else {
                    alert("No order data found.");
                }
            } catch (error) {
                console.error("Export failed:", error);
                alert("There was an error fetching the order data.");
            }
        }
    </script>
<?php }
add_action('admin_footer', 'custom_export_script');
function custom_order_export() {
    if (!current_user_can('manage_woocommerce')) {
        wp_send_json_error("Unauthorized", 403);
    }
    $orders = wc_get_orders(array(
        'limit' => -1,
        'orderby' => 'date',
        'order' => 'DESC',
        'return' => 'ids',
    ));
    $order_data = array();
    foreach ($orders as $order_id) {
        $order = wc_get_order($order_id);
        $order_data[] = array(
            'id' => $order->get_id(),
            'date' => $order->get_date_created()->date('Y-m-d H:i:s'),
            'status' => $order->get_status(),
            'total' => $order->get_total(),
        );
    }
    wp_send_json(array('orders' => $order_data));
}
add_action('wp_ajax_custom_order_export', 'custom_order_export');

https://wpml.org/forums/topic/woocommerce-analytics-report-not-downloading-for-other-currency-speed-issue-at-admin-side-2/page/2/#post-16351152

https://wpml.org/forums/topic/woocommerce-analytics-report-not-downloading-for-other-currency-speed-issue-at-admin-side-2/page/2/#post-16351442

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your specific case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please feel free to open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 22 replies, has 0 voices.

Last updated by Bigul 2 weeks, 1 day ago.

Assisted by: Bigul.

Author Posts
September 27, 2024 at 2:16 pm

sagiS

Background of the issue:
I have 2 issues on my website from WPML. The site I need help with is hidden link. I can share admin access as these issues are still not resolved.

Symptoms:
1. WooCommerce analytics report not downloading for other currency like USD, Euro. 2. Speed issue at admin side (Background queries slowing down my site).

Questions:
How can I resolve the issue of WooCommerce analytics report not downloading for other currencies like USD and Euro?
What steps can I take to address the speed issue at the admin side caused by background queries?

September 27, 2024 at 3:03 pm
October 1, 2024 at 4:15 am #16238206

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

We are still working on this issue and get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

October 3, 2024 at 4:02 pm #16251297

sagiS

Hello,
any update on this issue?

October 4, 2024 at 5:14 pm #16255481

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Sorry for the late response. We cross-checked your previous tickets in detail. It looks like a compatibility issue with customization.

So a couple of requests. Becuase last time we were not able to reproduce the issue exactly in a minimal setup (when WPML and must required plugins are activated with the 2023/2024 theme).

1) Please share a screencast of the exact steps you are following to reproduce the bug. It will help us a lot in our internal discussion.

2) Please share your staging site credentials. It was cleared just after moving the chat to a ticket.

--
Thanks!

Bigul

October 7, 2024 at 2:08 pm
October 8, 2024 at 8:20 am #16264331

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the details and the screencast. To make sure, the expected result (while filtering the Analytics report) in secondary currencies is the following. Please confirm.

- It should send an email
- It should not download files
- It should be showing inside email logs.

Also, one doubt about the following reply (of the previous ticket). The issue exists when all other plugins (except the must required ones) are inactive and the theme is 2024, am I correct?

https://wpml.org/forums/topic/woocommerce-analytics-report-not-downloading-for-other-currency/#post-16046446

If so, how you are sending the mail when we filter the report (I mean without the custom coding, we would like to know the exact settings, it will help us a lot in tracking this)?

--
Thanks!

Bigul

October 10, 2024 at 10:12 am #16274027

sagiS

1. Actually the default woocommerce functionality for Orders Report is when we click on Download button [ hidden link ] then directly it downloads that file but in our website only for USD and Euro it is misbehaving and sending email (most probably it is happening from your multi-currency plugin i.e WooCommerce Multilingual & Multicurrency because this is coming from your plugin not woocommerce).

2. All the custom work is done inside our custom theme voye so changing theme to twenty-twentyfour, still we are getting issues. Now you can disable the plugins and tell us from where the conflict is coming.

3. We have not done any custom code for sending email. Don't know why this is happening for the currencies like USD and Euro only.

October 10, 2024 at 4:27 pm #16276459

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the details. We will test it further on your staging site.

Also, please allow me to make a copy of your site using the Duplicator plugin (https://wordpress.org/plugins/duplicator/) for debugging the issue on my local server (in case of further debugging and escalation to our team).

--
Thanks!

Bigul

October 11, 2024 at 12:19 pm #16279604

sagiS

Hello,

You can do testing and debugging on our staging only as we have backup of website and you are not allowed to use other plugins. Your team also check the issue & debug the issue on this staging only.

Thanks

October 14, 2024 at 7:55 am #16284304

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the updates. We will test it further and get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

October 15, 2024 at 12:43 pm #16290753

sagiS

Hello Bigul,
any update on this issue ?

October 15, 2024 at 2:51 pm #16291500

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

We started debugging this issue. Unfortunately, we are not able to upgrade to the latest version of plugins. The result is the same after several tries.

Most of the plugins including WPML and WooCommerce need upgrades. As a part of debugging procedures, we have to make sure the issue exists in a minimal setup with the latest version.

Please check the attached images for more details. Therefore can you please check if you can upgrade to the latest versions or not?

--
Thanks!

Bigul

2024-10-15_20h16_28.png
2024-10-15_20h13_52.png
2024-10-15_19h37_32.png
October 18, 2024 at 6:54 am #16302830

sagiS

Hello,

Why you are updating plugins, it has nothing to do with that. Your plugins(WPML) should work with all the versions of woocommerce. Also we have not done any custom code inside the woocommerce plugins or in other plugins.

Updating plugins from Admin Panel is not possible. Anyways I have updated WooCommerce with the latest version.

Also if you want FTP access I can share with you. Please do it fast, we don't have time and need to solve this issue ASAP on Production.

If you are facing issue or can not solve this issue fast then please assign this to your senior representative/developer to debug this issue faster.

October 18, 2024 at 12:10 pm #16304629

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the updates and for upgrading the WooCommerce plugin. Please note that we have to reproduce the issue in a minimal setup with the latest version of the theme, plugins, and WordPress. Then only we can escalate it to our second-tier team and developers. That is why I tried to upgrade the plugins.

So we hope it will be okay to network deactivate the plugins in the staging site. Please confirm.

I am enabling the private option for the next reply. Please share the FTP credentials. We will try our best to resolve the issue as early as possible. Thank you for your kind understanding.

--
Thanks!

Bigul