Issue with updating 'spaces available' per class

Hey,

When a user books a class, the ‘spaces available’ (e.g. 8 spaces available) goes down by 1 (so the class would now have 7 spaces available for that particular time):

This system is working really nicely, except for one thing. When the class creator updates their class and clicks the ‘Update Listing’ button, it re-submits the spaces available dropdown (sometimes with a different number, if their class has grown or shrunk).

This is the workflow when a user re-submits/edits their listing. It makes changes to the listing + to the calendar in that listing.

The problem is that the spaces are then reset for all the calendar dates. This means that any listings which were already booked get full space availability again.

For example:

• CLASS creator sets spaces to 10.

• 3 people purchase their class for the 10th November. Spaces for the 10th November class = 7

• CLASS creator edits their listing and clicks the ‘Update listing’ button. Spaces for all classes (including the 10th November class) have reset back to 10.

This is where I’m a bit stuck.

Rather than just have ‘Spaces Available = Results of step 1’s Spaces Available’ in the update listing workflow, I wanted to add a ‘- number of booked spaces’ expression. So it would be "Spaces Available = Result of step 1’s Spaces Available - number of booked spaces’.

In the Booking Data Type, I’ve added a number field called Minus Spaces. I’ve also added the same number field for the CalendarScheduling Data Type if that’s a better way to go. I’m not sure how to save this for a booking and then call it up when I Updated the listing.

Ideally it would be: When class is booked, Minus Spaces = +1 for the CalendarScheduling date booked, then when I edit listing, Spaces Available = spaces dropdown’s value - Minus Spaces for relevant CalendarScheduling dates.

Editor: (removed)

Managed to fix this!

When a user books a class, I ‘make changes’ to 2 fields for Calendar dates:

1.) Spaces Available = This CalendarScheduling’s Spaces Available - 1

2.) Minus Spaces = This CalendarScheduling’s Minus Spaces + 1

Image:

Then when a user edits their listing, I make the following change to CalendarScheduling:

1.) Spaces Available = Result of step 1 (make changes to listing)'s Spaces Available - This CalendarScheduling’s Minus Spaces

Image:

So I’m essentially saying, when a listing is updated and the spaces available field is resubmitted, make sure that existing bookings are deducted from the spaces available for relevant classes.

Think I’m getting better at this stuff!

This topic was automatically closed after 70 days. New replies are no longer allowed.