[#575] Multiple products added when booking with count

Migrated from Redmine #575 | Author: Dhanushka Krishnajith
Status: Resolved | Priority: High, I’m very impatient | Created: 2020-09-23


I am adding products with multiple bookings. Below is the request.
Account: vicinitytest

{
    "jsonrpc": "2.0",
    "method": "book",
    "params": [
        "16",
        10,
        "2020-09-30",
        "10:00:00",
        {
            "name": "xx",
            "email": "xx",
            "phone": "xx"
        },
        {
            "ageRange": "26-49",
            "subscribe": true,
            "products":[{"id":"2","qty":1}]
        },
        2
    ],
    "id": 7
}

However, this adds product for each booking resulting in 2 products added. See the response from “getBookingCart” below. Is it possible to add product to just for the first booking while booking multiple? What is the recommended way of booking multiple and attach products to only to one?

{
    "result": {
        "amount": 68,
        "currency": "AUD",
        "cart": [
            {
                "booking_id": "190",
                "item_id": "16",
                "event_id": "16",
                "name": "Multi booking 1 09.30.2020 10:00 AM",
                "event_name": "Multi booking 1",
                "price": "10.0000",
                "currency": "AUD",
                "qty": 1,
                "type": "booking"
            },
            {
                "booking_id": "2",
                "item_id": "2",
                "price": "24.0000",
                "currency": "AUD",
                "qty": "1",
                "name": "Santa key ring",
                "type": "product"
            },
            {
                "booking_id": "191",
                "item_id": "16",
                "event_id": "16",
                "name": "Multi booking 1 09.30.2020 10:00 AM",
                "event_name": "Multi booking 1",
                "price": "10.0000",
                "currency": "AUD",
                "qty": 1,
                "type": "booking"
            },
            {
                "booking_id": "2",
                "item_id": "2",
                "price": "24.0000",
                "currency": "AUD",
                "qty": "1",
                "name": "Santa key ring",
                "type": "product"
            }
        ],
        "cart_id": "22",
        "cart_hash": "8056efe0b7f9e965d400daa0057b8aaa",
        "status": "not_paid"
    },
    "id": "5",
    "jsonrpc": "2.0"
}

Dmytro Bondarev wrote:

You are using group booking. And it adds all products for each booking.
If you need different products per booking please use multiple bookings.

  1. Make batch API documentation | SimplyBook.me Online Scheduling
  2. Call book method and pass batch id
  3. call method closeBatch($batchId, $batchType, $sign) , where
    $batchId - is your batch id from first step.
    $batchType - batch_multiple_booking
    $sign - md5($batchId . $hash . $secret).

As result of closeBatch you will receive object that contains array of bookings and invoice object.
You can confirm payment by calling confirmInvoice($id, $paymentSystem) of Admin API. (The confirming payment via public API is not available.)

Dhanushka Krishnajith wrote:

Thank you! This will work. However I am worried about the scenario where booking quantity cannot be completely fulfilled. Imagine if 3 slots were available at the time of selecting the slot but only two available when booking the slot (due to someone else booking it). That’s why I was looking to book all at the sametime, so that booking will fail if the total quantity isn’t available. I am not worried about product availability.