Proposals for a commerce booking system
Here are my thought about a new booking system integrating commerce in Drupal.
1. Create a new entity called Bookable Units
Bookable units are fieldable entities, as those proposed by the Rooms module but without hardcoded fields (like sleeps, etc...).
Ex: seats, cars, or any rentals products.
2. Create to availability calendar fields
I love the availability calendar module, with a few improvements (http://drupal.org/node/1800894) we would be able to do this:
Two availability calendar field for each bookable unit:
- one called "Stock calendar" which permit to define stocks on a calendar basis,
- one called "State calendar" for front view to display availability state.
Ex: there is 12 cars availables between 12/03/2013 and 12/04/2013, but only "Available" is showing for front users.
That allow for example to define stocks on 0 (unavailable) for holidays or on week ends.
3. Create a product and attach a bookable unit with an entity reference field
Several product can share same bookable unit
Ex: 2 difference travel tours with guides on same days, guides can be attached to both tours, if all guides are booked for one tour, there is no left guides for the other tour.
4. Create a date field on product line items: field_booking_date
A simple date field for add to cart form
5. Create a pre-calculated field on product line items: field_line_item_availability
A field returning stocks for product attached bookable unit, calculated from field_booking_date value and the bookable unit attached to product.
6. Create a general Rules event looping between each line items in a cart
Theses Rules are almost the same of commerce stocks module's rules :
Add to cart (or updating cart) and during all checkout steps
- If line item qty > line item stock (on chosen date) => cancel add to cart
- If total booked line items >= line item stock (on chosen date) => set State calendar on "unavailable"
I thinks this way is the easier as it use many of the features of existing modules, and provide great flexibility.
I need feedbacks on it, in case i'm wrong on specific points. Any help is welcome.