I am building an event booking system for a restaurant using Charge 2.0. Everything is working great, but having problems implementing a feature that shows how many spots are left.
An Event channel entry (created by the restaurant) provides parameters such as price, event name, etc and passes them to a Charge form. The Event entry also includes a field that specifies the maximum number of guests.
The Charge form includes a field for specifying a 'number of guests' for the booking. To indicate how many spots are left, we first need to calculate how many guests have already been booked, which is a simple matter of getting the 'numberOfGuests' field from all of the existing Charge entries and summing them. The problem arises when trying to filter the results using a Search parameter, which limits the entries to a specific event (the Event name is passed to the Charge description field). Here is a bit of the code:
{% set q = 'description:' ~ '"' ~ entry.title ~ '"' %}
{% for entry in craft.charge.charges().search(q) %}
//get the number of guests
I tried a few different things, including a wildcard search, and none of them return any results. Does anyone know if the Charge model supports a Search parameter?