Add Element in booking view page

Hi,
I tried a lot of things but I cant solve my problem.
I want to simply add a new element (for example a text label) in booking view page like this:

I tried this code but is not woking:

add_filter(
    'hivepress/v1/templates/booking_view_page',
    function ($args) {

        return hivepress()->helper->merge_trees(
            $args,
            [
                'blocks' => [
                    'page_content' => [
                        'blocks' => [
                            'booking_details_primary' => [
                                'blocks' => [

                                    'new_element' => [
                                        'label' => 'test label',
                                        'type'      => 'text',
                                        'attributes' => [
                                            'id' => 'booking_details_primary',
                                        ],
                                    ],
                            ],

                            ],
                        ],
                    ]
                ],
            ],
        );
    },
    1000
);

Thanks in advance!
Emilio

Hi,

You can use booking attributes, please check this doc How to add booking attributes - HivePress Help Center

Hi andri,
I need to make a custom element via code, also if I create a attribute I’m not able to access it via hook.

Thanks in advance.
Emilio.

Please try this PHP code snippet

add_filter(
    'hivepress/v1/templates/booking_view_page',
    function ($args) {

		return hivepress()->template->merge_blocks(
			$args,
			[
				'page_content' => [
                        'blocks' => [
                            'booking_details_primary' => [
                                'blocks' => [

                                    'new_element' => [
                                        'label' => 'test label',
                                        'type'      => 'content',
										'content' => '<div>Custom text</div>',
                                        'attributes' => [
                                            'id' => 'booking_details_primary',
                                        ],
                                    ],
                            ],

                            ],
                        ],
                    ]
			]
		);
    },
    1000
);
1 Like

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

I want to display informations about users on list of bookings,and on booking display, like this


How can i do this ? hook ? templates don’t work for bookings ?

Hi,

Please check the solution in this topic. Also, please note that it can require further customization.

Good evening Andrii,

Please could you reveal the snippet for that particular request?

Regarding:

  • User name, email, phone number

Is this to be entered into the child theme?

Many thanks in advance

Hi,

Please clarify, do you need to display the user’s username, email and phone number in the booking block and in the booking page for the vendor in its dashboard? If so, we can provide general guidance if you are familiar with coding or have a developer. Please let me know if this will work for you.

Hiya, yes spot on, what you have stated is correct.

Thank you!

Sorry for the delay.

The easiest way is to override one of the existing template parts, for example via a child theme. For example, you can override this template part:

hivepress-bookings/templates/booking/view/booking-status.php

Inside you can add custom HTML or PHP code. It’s possible to get the booking user this way:

$user=$booking->get_user();
echo $user->get_email();
echo $user->get_phone();
echo $user->get_username();

Hope this helps

1 Like