Answers.Body: <p>Developer of <a href="https://squarebit.co.uk/software/charge" rel="nofollow">Charge</a> here.</p>
  
  <p>Yes - Charge supports all the native Craft criteria search parameters for fields. </p>
  
  <p>Like you mentioned, there are a few special fields that aren't supported currently within that. Those are fields like <code>description</code>, <code>notes</code> etc.. The <strong>supported</strong> direct attributes on the Charge model that can be searched (in addition to all the basic ElementType attributes) are : </p>
  
  <ul>
  <li><code>userId</code></li>
  <li><code>sourceUrl</code></li>
  <li><code>timestamp</code></li>
  <li><code>hash</code></li>
  <li><code>customerId</code></li>
  <li><code>mode</code></li>
  <li><code>meta</code></li>
  </ul>
  
  <p>This is in addition to all Craft fields you might have attached to the charges. </p>
  
  <p>For example - if I wanted to find all the charges based on a specific <code>customerId</code> (the stripe identifier), it'd look something like this : </p>
  
  <pre><code>{% set charges = craft.charge.charges({ customerId : 'cus_00000000' }) %}
  </code></pre>
  
  <p>They can be of course be combined, so all charges for that customer only in live mode : </p>
  
  <pre><code>{% set charges = craft.charge.charges({ mode: 'live', customerId : 'cus_00000000' }) %}
  </code></pre>
  
  <p>If we had a field on the charge model with a name of <code>ourCustomField</code>, we could search for that like : </p>
  
  <pre><code>{% set charges = craft.charge.charges({ search : { query : 'ourCustomField:' ~ someSearchValue }}) %}
  </code></pre>
  
  <p>And also, we could combine all those into a single thing too:</p>
  
  <pre><code>{% set charges = craft.charge.charges(
     { mode: 'live', 
       customerId : 'cus_00000000', 
       search : { 
          query : 'ourCustomField:' ~ someSearchValue 
     }}) %}
  </code></pre>
  
  <p>Or in the alternative syntax, that could be: </p>
  
  <pre><code>{% set q = 'ourCustomField:' ~ someSearchValue %}
  {% set charges = craft.charge.charges()
        .customerId('cus_00000000')
        .mode('live')
        .search(q) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-20T15:06:31.473Z
Answers.Text: Thanks, Joel. I ended up adding another field to Charge that stores the event entry ID, and all is good. Loving Charge 2.1 - building a fairly complex restaurant booking system around it that includes a ton a features for the restaurant staff to manage reservations, refund cancellations, and much more!
Answers.UserDisplayName: Roi Agneta
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T12:06:46.857Z
Answers.LastActivityDate: 2016-07-19T12:06:46.857Z
Answers.UserDisplayName: Joel Bradbury
Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>{% set q = 'description:' ~ '"' ~ entry.title ~ '"' %}
  {% for entry in craft.charge.charges().search(q) %}
     //get the number of guests
  </code></pre>
  
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-17T21:48:04.553Z
Comments.Text: Upon further testing it seems the Search parameter will work with custom fields, but seemingly not with the Charge 'description' field. If I print the Charge description field it returns the expected values.
Comments.UserDisplayName: Roi Agneta
Tags: <search><plugin-charge>
Title: Booking system based on Charge 2.0
ThreadText: # Booking system based on Charge 2.0
  
  (Asked by: username_0 on 2016-07-17)
  
  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?
  
  **Tags:** search, plugin-charge
  
  > **Comments:**
  > **username_0**: Upon further testing it seems the Search parameter will work with custom fields, but seemingly not with the Charge 'description' field. If I print the Charge description field it returns the expected values.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-19. Score: 3
  
  Developer of [Charge](https://squarebit.co.uk/software/charge) here.
  
  Yes - Charge supports all the native Craft criteria search parameters for fields.
  
  Like you mentioned, there are a few special fields that aren't supported currently within that. Those are fields like `description`, `notes` etc.. The **supported** direct attributes on the Charge model that can be searched (in addition to all the basic ElementType attributes) are :
  
  * `userId`
  * `sourceUrl`
  * `timestamp`
  * `hash`
  * `customerId`
  * `mode`
  * `meta`
  
  This is in addition to all Craft fields you might have attached to the charges.
  
  For example - if I wanted to find all the charges based on a specific `customerId` (the stripe identifier), it'd look something like this :
  
  ```
  {% set charges = craft.charge.charges({ customerId : 'cus_00000000' }) %}
  
  ```
  
  They can be of course be combined, so all charges for that customer only in live mode :
  
  ```
  {% set charges = craft.charge.charges({ mode: 'live', customerId : 'cus_00000000' }) %}
  
  ```
  
  If we had a field on the charge model with a name of `ourCustomField`, we could search for that like :
  
  ```
  {% set charges = craft.charge.charges({ search : { query : 'ourCustomField:' ~ someSearchValue }}) %}
  
  ```
  
  And also, we could combine all those into a single thing too:
  
  ```
  {% set charges = craft.charge.charges(
     { mode: 'live', 
       customerId : 'cus_00000000', 
       search : { 
          query : 'ourCustomField:' ~ someSearchValue 
     }}) %}
  
  ```
  
  Or in the alternative syntax, that could be:
  
  ```
  {% set q = 'ourCustomField:' ~ someSearchValue %}
  {% set charges = craft.charge.charges()
        .customerId('cus_00000000')
        .mode('live')
        .search(q) %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, username_1. I ended up adding another field to Charge that stores the event entry ID, and all is good. Loving Charge 2.1 - building a fairly complex restaurant booking system around it that includes a ton a features for the restaurant staff to manage reservations, refund cancellations, and much more!  
  
  ---
  
  