How to get Booking object from template

I’m using a hook hivepress/v1/templates/booking_view_page/blocks
Inside this hook I’m trying to get the booking ID.
I’m using:
$booking= HivePress\Models\Booking::query()->get_by_id( get_post() );
but no success, I’m getting the first blog post, can you explain what is happening?
Why get_post() is not getting the current post.
I did the same for request and I got success, I got the ID of the request.
As workaround I’m getting the ID of booking from URL.


If I understand you correctly, please check this topic How to get data from bookings

​I hope this is helpful to you.

My problem is to get $booking object.
In this hook “hivepress/v1/templates/booking_view_page/blocks” is available?


You also need to use the second parameter of the hook $template object , and then use $template->get_context(‘booking’).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.