Support » Fixing WordPress » Autocompleting booking

  • Hi All,

    I am looking to autocomplete bookings made via “Woocommerce bookings” when their end date has past. We automatically send emails to completed orders and would like to automate the process of completing the order once the bookings end date passes.

    I am aware that there are other forums for this but I mainly used wordpress.org to get in touch with @jessepearson . I had come across this code: https://gist.github.com/jessepearson/27a0b073113b41d6b415b584cb7ad7c9

    I would like to know if it could be adapted to what I need? To be honest I am not a .php developer so I am not even sure how to apply the code found on the github? Whether it replaces the original code, works as an addition or runs as a separate script?

    Any help anyone could provide would be amazing!

    Thank you!

    Donovan R.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Jesse Pearson

    (@jessepearson)

    Automattic Happiness Engineer

    @donrucastle Bookings should auto complete themselves after their date has passed, there’s a cron event that is set for each booking to do this. If it isn’t working, log into your WooCommerce.com account and submit a ticket and someone will be able to help you troubleshoot that.

    @donrucastle Bookings do auto complete themselves, but not all orders do. Only orders for virtual and downloadable products auto complete themselves. If you want to autocomplete orders which has status processing, has only bookable products in them, when all bookings are completed, you can use my gist:

    Hi @marale

    Thank for providing that!

    Excuse my lack of knowledge but will that code provided, only complete orders once the bookings end date has passed? I am unaware if bookings auto-complete based on their end dates.

    Also where and how would I implement that code you linked?

    Hi @donrucastle

    Yes it will complete orders once the last booking in the order end date has passed (if there are only bookable products in the order).

    You can put that code in your child theme’s function.php file through code editor in the dashboard, or you can use a Code Snippets plugin to implement it.

    • This reply was modified 2 years, 8 months ago by marale.

    Hi @marale

    I apologize for the late response, I have been managing a few things with the site and only had the chance to implement your code over the last few days.

    While I have had it inserted correctly, it is not running correctly. I originally assumed it would change all orders even dating back to the start of the site to complete if it had a booking. This did not happen. I then waited for a recent booking to complete to see if it would do the same for the order. Unfortunately, it did not.

    Currently, the site only provides bookings(no other products) is it perhaps a plugin which is interfering with the part of the code which checks if there is only a booking linked to the order?

    I highly appreciate your help so far and would be interested in your thoughts on what I could troubleshoot next!

    Thank you again!

    Hi @donrucastle

    While I have had it inserted correctly, it is not running correctly. I originally assumed it would change all orders even dating back to the start of the site to complete if it had a booking. This did not happen. I then waited for a recent booking to complete to see if it would do the same for the order. Unfortunately, it did not.

    There was a little bug in the code :), sorry for that. In the last line ‘wc_booking_complete’ should be ‘wc-booking-complete’. I have updated the gist.

    If you want to change the status of all orders dating back, uncomment(remove ‘//’ at the beginning of the line) the last line of my gist. I haven’t tested it for large amount of orders. If you send emails when an order becomes complete, all emails will be send, is it what you excpect ?

    Please let me know if it works.

    • This reply was modified 2 years, 7 months ago by marale.

    Hi @marale

    Thanks so much for this! The code works brilliantly now.

    I did try and use the commented out line at the bottom to complete all orders but it ended up causing an error. I assume it was because we would be completing over 300 orders at once. I did not pursue it further to check.

    Thanks again,
    Donovan R.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Autocompleting booking’ is closed to new replies.