• Hi,

    We use the WooCommerce API to sync the orders from WooCommerce in our own system. For this we use the endpoint:
    /wp-json/wc/v3/orders?updated_at_min=2020-03-10T00:00:00Z&per_page=10

    This gives us all the info needed. Now we want to start using WooCommerce Bookings. Unfortunately the booking period is not included within the above call.

    I have found that I could call:
    /wp-json/wc-bookings/v1/bookings
    to list all bookings. But as more and more orders are coming in, this is going to be a large list. So, I want to filter on order_id or order_item_id

    I’ve tried things like:
    /wp-json/wc-bookings/v1/bookings?order_id=12345
    /wp-json/wc-bookings/v1/bookings?order_item_id=321
    wp-json/wc-bookings/v1/bookings?filter[order_id]=12345
    wp-json/wc-bookings/v1/bookings?filter[order_item_id]=321

    This all seems to not do anything, it returns the same bookings even when I change the order or order item id to something that does not exist.

    I’ve tried to look at this page: https://docs.woocommerce.com/document/bookings-action-and-filter-reference/
    Unfortunately I have no idea how to use this. I could find woocommerce_booking_json_search_order_number which should “The order number being searched for when editing a booking.” but adding this to the url doesn’t work.

    Any help would be appreciated, thanks.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    The documentation for the Bookings REST API is available here:
    https://docs.woocommerce.com/document/bookings-rest-api-reference/

    The section for getting Bookings via the API is in the bottom section, however it does not look like there are any available properties for filtering the response (as there are properties for filtering slots).

    I did some testing as well, and while the properties for filtering slots worked, filtering did not seem to work for retrieving Bookings: i.e.
    /wp-json/wc-bookings/v1/bookings?order_id=29993

    It looks that is not currently built into the Bookings REST API. It would be great to have you add that to the Ideas board here: http://ideas.woocommerce.com/forums/133476-woocommerce

    In the meantime, it looks like adding that would require customization. If you need assistance with coding or custom development, we recommend reaching out to a developer from one of the services at https://woocommerce.com/customizations/.

    I hope that helps!

    Thread Starter cularbytes

    (@cularbytes)

    Hi Kellymetal,

    Thanks for your reply. Are there any other filter options available for the bookings? Like get all the bookings after a certain date_created or start, or by product_id? ANYTHING that can do the job of not having to load ALL bookings? I can’t really imagine that this question hasn’t been asked before because it seems so obvious that it would be a huge performance bottlenack of all bookings have the be retrieved every time.

    Creating a new suggestion would take years before such a thing is being upvoted enough and planned/in development, where customizations leads to an plugin version we can’t update anymore (?).

    It would really help if a quickfix could be implemented, a simple filter option shouldn’t take that long?

    kpress

    (@kpress)

    Hi cularbytes,

    It does not accept order_id or order_item_id. You can get all the endpoints and parameters by entering <your-domain>/wp-json/wc-bookings/v1 in FireFox. FireFox does a nice job of displaying the endpoints and the parameters.

    You should see a list of all the endpoints for bookings after you enter <your-domain>/wp-json/wc-bookings/v1 in FireFox. I think the “after” parameter should be what you need. I try “wp-json/wc-bookings/v1/bookings?after=2019-11-05T08:15:30-05:00” and it returns a list of bookings. Give it a try.

    I want to attach a screenshot of the parameters but I don’t see a way to do that here.

    Good luck.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce Bookings REST Api Bookings order filter’ is closed to new replies.