Booking multiple items at once?

edited January 2014 in Developers
I'm writing a Wordpress plugin that does my own workflow for booking, and one of the things the client wants is to be able to book multiple different things at the same time - i.e. 2 of Item A and 3 of item B for a certain time frame. I can do the booking form, but since each item produces its own SLIP, I'm getting the impression that for payment I'm going to have to send the end user to the payment form once for item A and once for item B. Needless to say, that's not what the client wants. Is my only option to do my own payments by calling the Stripe API?

Comments

  • edited January 2014
    A booking session is able to store a group of items and act as a 'cart' storing the items you've selected across requests.  You'll only need to finalize the session when you are ready to go through to the payment form.

    To add items to an existing session, just specify the session_id (either in a query parameter or a cookie) in a booking/session call, along with your added item slip(s).  You can also add multiple different items to a session in the same call by sending slip parameters as an array (i.e. slip[]=SLIP1&slip[]=SLIP2), which works on both existing and new sessions.

    Within every response to a session call, you'll receive an updated account of your current session, containing a listing of line items in your proposed booking.  Using the 'alter' array parameter in a booking/session call, you'll be able to modify existing entries in your session: for example, using alter[3]=5 would change the quantity of line item 3 to 5 units; using alter[3]=remove would remove that item from your booking.  For items with package options, optin or optout on the option's line item can be used for option selection.
  • I guess I missed that in the documentation it says I can specify more than one SLIP when creating the session. Thanks.

    So given I've got one page where the end user is picking the date range of the booking, and also how many of each type, and then when they've got all that they go onto the next page to enter their booking fields, I gather that this the general workflow:

    1. $this->get('/item') to get the item infomation
    2. Display that on the form
    3. Each time the user chooses /changes their date range or the number of each item, make an AJAX call to check availability and get the SLIP for that item.
    4. Once they hit submit on that page, use the SLIPs for each item from the last call and create the session.
    5. Call $this->get('/booking/form') to get the fields and display them.
    6. When they hit submit on that page, call $this->get('/booking/create') with the session id from step 4 and the info from the form fields to create the booking.
    7. Redirect to the returned completion URL.

    Does that look right?

    As an aside, by the way, CheckfrontAPI.php has the comment
    // @see session_create()
    But there is no session_create(). Also, I can't find any reason for the abstract function "session($session_id, $data)" since it doesn't seem to be used for anything - it's called by "set_session", but nobody calls it as far as I can tell.
  • Yep, that sounds like it should work.  I would use $this->post($path,$data) when submitting data with the SDK, however.  
    The booking/form fields are tied to account-wide settings, so could justifiably be cached for a bit if you don't expect them to change often and wanted to shave off a tiny bit of request time.

    Some of the SDK functions are used for examples or are part of older API versions.  I believe the abstract session function is called by each API request, and submits the current session_id as a parameter - you should see one or two of the example files popping this into the session.  If it's useful for your app, it's there, but if not, the SDK should be easy to modify to fit your application.
This discussion has been closed.