Teo thanks for your reply.
The condition is checking there are any records in the database. Basically it is a temporary shopping cart table (holiday booking system), and this API is a stripe endpoint. If the shopper purchased anything then the records are inserted into a calendar table by selecting the data from the repeat. There is nothing in the else clause yet, but it will check if the shopper purchased any add-ons. These will then be marked as paid.