2

I am making/trying to make a reservation system with Craft. Logged-in members should be able to make a reservation for a hotel room on the front-end, and change it later.

I am keeping a stock for the available hotel rooms in entries. I have channel section called "rooms". In that section are 2 entries (= 2 different hotels). Every entry has information about the hotel (name, location,...) and has a matrix field with avaialble dates and stock for that date.

What I want to do: a logged-in user can choose a date and choose a number of rooms on that date. He should also fill in all his personal details. I was thinking about making entries of that info in a new channel (e.g. "reservations"). The hard part is: when a user selects a number of rooms, I want the stock of that night edited in the rooms entry. So if we heve 20 rooms available, and a member makes a reservation for 2, the stock should be set to 18.

I guess the first answer to this will be "write a plugin", but I have never written a plugin before, and I have no idea what's the best practice or where to start. Any ideas?

2 Answers 2

2

Couldn't you have multiple forms on the page, and submit them via AJAX in sequence when the user clicks on the Submit button?

1

I guess the first answer to this will be "write a plugin"

I guess you're right. :)

Your plugin would have a controller that your front-end form posts to. From there you grab all of the needed data from POST and perform any custom business logic you want, including saving multiple entries.

The official plugin docs are here: http://buildwithcraft.com/docs/plugins/introduction

There is also a Craft Plugin Development course on Mijingo that I've heard good things about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.