Ensure that cancellations cannot be made after payment

With the help of this page, we were able to hide the Cancel button only when ‘Processing’.

In the same way, I want to make it impossible to cancel an order that has been paid for.
We want to ensure that neither the user nor the vendor can cancel an order for which payment has been completed.
Only the operator can cancel.
Is it possible to do so?
Thank you.

Hi,

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 || !in_array($order_status, ['processing', 'completed'])){ 
      return $blocks; 
    } 
  
   hivepress()->template->fetch_block($blocks, 'booking_cancel_link');
   
    return $blocks;
  },  
  1000, 
  2 
);

Please note that it can require further customization.

1 Like

Thank you! You’ve been a great help!!

Wow! This code works for the vendor and for the user. That’s great!

Thanks!

2 Likes

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