Support » Plugin: WooCommerce Admin » Is it possible to schedule the wc-admin-data actions to run overnight

  • Resolved lippiun



    Since the latest WooCommerce update which introduced the new admin functionality, we have noticed hundreds of pending actions which import the orders and customers. The issue with this is we have other actions running which are vital to the website we are running properly and which get delayed due to the high volume of orders we receive which generate a new action for each.

    I’ve tried stopping the historical import in the settings page but this doesn’t work for some reason and when i refresh the page, the update automatically starts again.

    My question is, is it possible to specify a specific time to run the admin import actions or set a priority so the other actions run before? I’ve noticed the actions from the admin run a lot slower than typical actions.

    The admin data is not something we need to access on the fly so having the ability to do this overnight once a week would make much more sense. I’m aware you can run these via the CLI but WPEngine don’t allow this yet.

    Many thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeff Stieler


    Hello Shaun @lippiun,

    We’ve added the wc-admin-data group to all scheduled actions, but that feature isn’t in use by Action Scheduler just yet unless you are running it via WP-CLI.

    In order to change the prioritization of actions, you’d likely need to subclass ActionScheduler_DBStore and sub it in so you could modify the query used to claim actions – including an order by group ID or similar.

    Claim actions:

    Filter to swap in your class:

    Thread Starter lippiun


    Hi Jeff,

    Thanks for getting back to me.

    I’ve had a look at the two links you provided and have managed to setup a custom data store class to override the default claim_actions method. The issue i have now is i can’t seem to target the specific WC Admin hooks or group in this method and when i try printing out these values in the error log, the only one which gets returned is the claim_id which doesn’t correlate to anything in the database.

    I’ve also noticed there’s a method called save_action which i’ve also overridden which does give me everything i need to manipulate the scheduled date. Is this the correct method i need to use or is it possible via claim_actions?

    Plugin Author Jeff Stieler


    The issue i have now is i can’t seem to target the specific WC Admin hooks or group in this method

    How are you attempting to do so?

    My initial idea was that you’d modify the claim query to sort actions using the group ID so that more important groups (e.g. NOT wc-admin-data) would always be claimed first.

    There are several ways you can accomplish this, but one way could be to set an ORDER BY that always puts one (or more) group_ids last.

    In my local test store, the wc-admin-notes and wc-admin-data groups are 2 and 3:

    Group IDs

    So I can force those group_ids to be claimed after all other groups by having a query like:

    SELECT action_id, hook, status, group_id
    FROM wp_actionscheduler_actions
    ORDER BY FIELD( group_id, 3, 2 ) ASC

    Note – don’t use this exact query above, this is an example of using the FIELD() function.

    I think it will be best to incorporate the ORDER BY FIELD() into the existing query issued by claim_actions().

    Happy hacking!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is it possible to schedule the wc-admin-data actions to run overnight’ is closed to new replies.