Hello,
I want the “Cancel booking” button to be cleared when the payment is: pending or when the booking is paid. To force users to request cancellation via my contact page.
I’ve tried this code but it doesn’t work:
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();
$allowed_statuses = array('pending payment', 'failed', 'processing', 'completed', 'on hold', 'awaiting payment', 'cancelled');
if(!in_array($order_status, $allowed_statuses)){
return $blocks;
}
return hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
'blocks' => [
'booking_cancel_link' => [
'type' => 'content',
],
],
]
)['blocks'];
},
1000,
2
);