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