Hide Cancel Booking Button on Booking Details Page when Status of Order is Processing

Our scenario involves Manual Payouts to be clear on my question below.

When the order status of a booking in WooCommerce is “Processing” can we hide the “Cancel Booking” button if a user goes to the booking details page to view that booking?

Technically the only way a user should be able to cancel a booking at this point is by submitting a “dispute” on the order details page.

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

Thanks,
Tom

1 Like

Canceling the booking itself doesn’t trigger a refund automatically, this depends on the website and/or host terms, so it’s always there just to give the ability to let the host know that the customer will not show up, this also frees the booking dates in the calendar (allowing for another booking to be made). If you want to hide this link anyway please try this CSS snippet:

.hp-booking .hp-listing__action--cancel {display:none!important}

I only want to hide this cancel button when the WooCommerce order status is “Processing”. A booking should still be able to be cancelled if a payment hasn’t been made.

The code you gave me will just hide the cancel booking button always.

Please try this PHP snippet

add_filter( 
	'hivepress/v1/templates/booking_view_page/blocks', 
	function ($blocks, $template){
		
		$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
);
2 Likes

By the way thank you Yevhen. This does work as we needed it to.

-Tom

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