Simple order cancellation in Drupal Commerce, with 24 hour time limit? I want to create a way for customers to log in and edit their completed orders (the orders are registrations to classes). Compared to the standard order-edit page I want to remove all options except 'change order status to cancelled'. Preferably a simple page stating the content of the order, then some cancellation 'rules', and then a button saying 'cancel this order'. 

Cancellation should then also check whether date/time of the booked class is less than 24 hours away from the moment of cancellation. If &lt;24 hours, it should either refuse cancellation, or allow cancellation (nice for those on the waiting list), but not refund the cost of the class (paid for using a voucher - using the giftcard module) 

Background: the site sells two products: one is a set of vouchers. These vouchers can then be used to buy product 2, which is a registration to a class at a specific date and time. When customers have booked a class, they now get an email with link to their order page. Their they find a button 'edit order', click that and you go to the standard order edit page which shows line-items, billing and shipping etc, and allows all existing changes to the order status. As this page is not made trough either a template or a view, I have no clue how to change what customers get to see and do with their completed order. 

Also rules does not allow me to compare the time of the status change with the time/date field of the booked class, so I can't control the 24 hour limit either..

Suggestions are to build a custom module doing the above, but I have no idea how to kick that off.. 

All/any help massively appreciated
I haven't tested any of this, but you might some of the following useful:

Entity Operations allows you to take a Rule and turn it into a menu tab. This would be one way of getting that onto the order view page.

Something I've really been wanting to try is the Entity action links sandbox:


  Allows actions and rules components to be executed via AJAX links on entity view.


Just note the patches discuss in the Sandbox README.

If you wanted to do the Rules route, these would be probably your best option, because you can use conditions and components to provide some sort of response or action system based on the order status and time.

Otherwise, you'd need to create a custom module with a custom access callback that does the appropriate checks and then executes the action if allowed. (For a developer, I think this would actually be an easier route.) But the rules stuff is intriguing.