• How can I run the woo_cao_cron hook more often?

    Any help appreciated.

    Kind regards.

    • This topic was modified 2 years, 4 months ago by ovirex.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author RVOLA

    (@rvola)

    Hello @ovirex
    The hour setting is per minute, isn’t that enough?

    A heavy redesign of the plugin is planned to simplify certain settings and improve performance.

    Thread Starter ovirex

    (@ovirex)

    Hi @rvola. Thank you for anwsering.

    Nono, I mean the hook woo_cao_cron, the one that you see in Scheduled Actions. That one is always set to 1 hour. The one in the woocommerce payment settings is alright as it is.

    The way I understand the plugin works is. You set how long an order is going to be in on-hold status until it gets automatically cancelled. That could be 1 hour, 10 hours, 10 days. But, the function/hook that checks if there are any orders that past their time and should be cancelled is woo_cao_cron. And that function runs every 1 hour.

    Correct me if I’m wrong in something.

    So, what I need is to check more often if a order should be cancelled.

    Let me know if that’s possible, I was thinking maybe with WPCrontrol.

    Kind regards.

    Plugin Author RVOLA

    (@rvola)

    Yes the plugin being written before action-scheduler and knowing the faulty cron of WordPress it was decided a daily recurring task. Then people wanted to reduce this time to an hour.

    For convenience and simplicity the plugin launches the cron task every hour and checks if the settings of each payment AND if orders are in this case to be canceled.

    Running the cron job more often will not change the speed of the plugin because it always refers to the delay in the options.

    One way to “cheat” would be:
    * speed up the recurring task with the cron
    * modify the calculated delay of the options by this filter: https://github.com/rvola/woo-cancel-abandoned-order/wiki/Change-the-calculation-date-for-orders

    Thread Starter ovirex

    (@ovirex)

    Let me see what I can do and I write you back.

    Cheers.

    Thread Starter ovirex

    (@ovirex)

    Hi again @rvola. What I tried didn’t work ??.

    I disable the wp cron and run the crons from server every 5 minutes.

    But doing that didn’t solve the problem. A order that was made at 3:58 should be canceled at 4:58. But It was canceled at 5:50. So. To fix that. Is the second “cheat” the way?

    One way to “cheat” would be:
    * speed up the recurring task with the cron
    * modify the calculated delay of the options by this filter: https://github.com/rvola/woo-cancel-abandoned-order/wiki/Change-the-calculation-date-for-orders

    Plugin Author RVOLA

    (@rvola)

    normally 1 hour after the sale it should be canceled.
    If the order is canceled at 5:50 p.m., the cron is only started at 5:50 p.m.
    The ideal when you have a site with a lot of cache, is to force the cron of WP with a recurring task on the server which wakes up wp-cron.php every hour.

    Then there may actually be a lag between the time of the order and the time of the cancellation.

    To understand this, you have to look at the time of passage of woocao in action-scheduler.

    In my example it goes to 8:58.
    This means that if the WP cron works it will go to 9:58, 10:58, 11:58 etc…
    If an order is placed at 9:15 a.m. and should be canceled “theoretically” at 10:15 a.m., it will actually be canceled at 10:58 a.m.
    Because when the woocao task is activated at 9:58 a.m. it will ask: “Give me the orders that are over 1 hour old and must be cancelled. However, the 9:15 a.m. order does not yet have 1 hour.
    At the passage of 10:58 this time it will be canceled.

    From what I see I think it’s the WP cron task that is not activated in time.
    Here are ways to force WP cron: https://ploi.io/documentation/optimisations/run-wordpress-cron-manually

    Thread Starter ovirex

    (@ovirex)

    Hi @rvola. Thanks for answering once again.

    Because when the woocao task is activated at 9:58 a.m. it will ask: “Give me the orders that are over 1 hour old and must be cancelled. However, the 9:15 a.m. order does not yet have 1 hour.
    At the passage of 10:58 this time it will be canceled.

    In this case. Shouln’t it be better to be able to set that time? So instead of being a fixed time the user can change it for convenience. Or there is a way for changing that?

    I just did what you told me. I’m using a cpanel server so the config is something like this: /usr/local/bin/php /home/mysite/public_html/wp-cron.php

    But after reading this. I think is something more like this: wget -q -O – https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

    I’m running the cron from server every 5 minutes.

    So. I can run the wp cron more often so there’s no “delay”. But either way, If I got an order at 4:45 an woo_cao_cron runs at 5:10. Then the order will be cancelled at 6:10 and not at 5:45. Right?

    Sorry If I didn’t get what you said. I’m sleep deprived hehe.

    Kind regards.

    Plugin Author RVOLA

    (@rvola)

    no problem with wp-cron, in the idea you have the right method. Manually activate wp-cron.php to wake it often.

    Yes for your explanation you are right, this is how it happens.

    To be honest with action-scheduler I could do much better now but I’m sorely lacking in time and this year is extremely complicated for me (I’m independent).

    It’s “free” time that I give, that’s why I adjust my priorities.

    Thread Starter ovirex

    (@ovirex)

    Then there’s always gonna be that “delay” or the possibilite that the order gets cancelled out of time. There’s nothing It can be done at the moment. The best thing I can do is run the wp-cron frequently so I don’t have to deal with the low traffic “delay” too.

    Either way, thank you very much for all your help. I really appreciate that you answer me.

    I would like to help you with the plugin. But my php skills… welp… I’m not proud of them ??.

    Kind regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Cron recurrence’ is closed to new replies.