Hide “Cancel Booking” after booking is completed only users

We want to hide the cancel reservation button only for users or buyers.

We want only the vendor to be able to cancel the reservation from the reservation details page.

Is there a PHP Snippet that can be provided to easily do this?

Thanks,

Hi,

Please check the solution in this topic Hide Cancel Booking Button on Booking Details Page when Status of Order is Processing - #3 by ihor

P.S. If you purchased a theme or extension, please enter the license key in the forum profile settings, this will enable the Premium Support badge and ensure a 24-hour turnaround time.

Hi,

I am currently using this code on my site but I would like it to only be hidden from the user or buyer

We would like the host to have the option to cancel reservations.

Can you help me with a PHP Snippet, please?

Thanks,

Thank you for waiting. Please try this PHP code snippet but please note that it can require further customization.

add_filter( 
	'hivepress/v1/templates/booking_view_page/blocks', 
	function ($blocks, $template){
		
		if(current_user_can('edit_posts')){
			return $blocks;
		}
		
		$order = $template->get_context('order');
		
		if(!$order){
			return $blocks;
		}
		
		$order_status = $order->get_status();
		
		if(!$order_status || 'processing' !== $order_status){
			return $blocks;
		}
		
		return hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
					[
						'blocks' => [
							'booking_cancel_link' => [
								'type' => 'content',
							],
						],
				]
				)['blocks'];
	}, 
	1000,
	2
);

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