=== Studio Class Passes ===
Contributors: starlink1207
Tags: class pass, booking, yoga, pilates, schedule
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sell 5- and 10-class passes with WooCommerce and let members book classes. Each booking uses one credit.

== Description ==

Studio Class Passes is for yoga, pilates and dance studios, music or tutoring schools and solo instructors who sell class packs. Sell passes as normal WooCommerce products. Members then book classes from a weekly schedule, and each booking uses one credit from their pass.

= Why this plugin =

* **No per-booking fees and no monthly SaaS bill.** Payments go through your own WooCommerce payment gateway, straight to you.
* **Everything a studio needs is free, with no limits.** Class packs, booking, credit history, the late-cancel and no-show policy, drop-in "Buy & book" and calendar links are all in the free version, with no limits on classes, members or bookings.
* **One plugin instead of three.** No need to combine a bookings plugin with gift-card and min/max quantity add-ons to sell class packs.
* **No overbooking, no double booking.** Seats and credits are taken and restored with atomic database updates, even when many members book at the same moment.
* **Fits your site.** Works with any theme (block or classic), the block or classic checkout, and is compatible with WooCommerce High-Performance Order Storage (HPOS).
* **Upgrade only if you need more.** Pro adds recurring classes, waitlist auto-booking, confirmation, reminder and expiry emails, unlimited passes, instructor accounts and CSV export.

**Class pass products**

* Tick "Class pass" on any WooCommerce product and set the number of classes and the validity in days.
* Credits are issued to the customer's account once per order when the order becomes Processing or Completed.
* If the order is refunded or cancelled, the unused credits are taken back automatically.
* Guest checkout is turned off for carts that contain a pass, because credits need an account.

**Class schedule**

* Add classes under WooCommerce > Class Passes: name, instructor, date, start and end time, capacity and location.
* Dates and times use your site timezone.
* Cancelling a class refunds every booked member.

**Booking**

* Show the weekly schedule with the `[class_pass_schedule]` shortcode or the "Class Pass Schedule" block. Visitors can move to the previous or next week.
* Logged-in members see their balance at the top: "You have 7 class credits · next expiry 12 Jan", with a link to buy more.
* Members book with one click. The credit comes from the valid pass that expires first.
* Members can cancel until the cancellation deadline (default: 12 hours before the class) and get the credit back.

**Drop-in "Buy & book"**

* Choose a 1-class pass product as the drop-in for all classes, or set a different one (or none) per class.
* A member with no usable credit sees "Buy & book (price)" on classes with free seats. The cart and checkout show which class it is for ("For: Yoga Flow, Mon 9:00").
* When the order is paid, the 1-credit pass is issued and the class is booked automatically. If the class filled up or started in the meantime, the credit stays on the account and the member is told.
* Guests see "Log in to book" and come back to the same class after logging in.

**Late-cancel and no-show policy**

* After the deadline, members can still free their seat with "Late cancel" (you can switch this off). The seat opens up for others, the credit stays used — or is given back if you prefer a softer policy.
* Mark each booking as attended or no-show on the class roster.
* Late cancels and no-shows are written to the credit history, and the members list and member page show the counts for the last 30 days.

**Add to calendar**

* Every booking has "Add to calendar": a downloadable .ics file (Apple Calendar, Outlook) and a Google Calendar link. After cancelling, the .ics file removes the event again.
* Each member gets a private subscribe link that shows all their upcoming classes in their own calendar app, with a button to create a new link.
* Built from your own booking data. No third-party calendar API to connect, nothing to sync, no external requests.

**My Account > Class Passes**

* Credits left and expiry dates, with an "expires in N days" badge that turns into a warning in the last week.
* Upcoming bookings with Cancel or Late cancel and calendar links, and past classes with their status.
* A full credit history (booked, cancelled, late cancel, no-show, adjusted by staff, refund, expired), page by page, with no length limit.

**Studio tools**

* A roster for each class, with attendance check-in, no-shows, staff cancellation and booking on behalf of a member.
* A member view with every pass, manual credit adjustments (a reason is required), expiry changes, manual passes (for example for cash payments) and a full credit history.

A Pro version adds recurring classes (create a whole term by weekday and date range), a waitlist that books the next member automatically and emails them when a spot opens, booking confirmation and reminder emails, expiry and low-credit reminder emails with a one-click "Buy again" link, unlimited (time-based) passes such as a monthly unlimited with optional fair-use limits, instructor accounts with their own roster and attendance in My Account, a schedule filter by instructor, and CSV export of rosters and credit usage.

== Installation ==

1. Install and activate WooCommerce.
2. Upload the `studio-class-passes` folder to `/wp-content/plugins/`, or install it from the Plugins screen, then activate it.
3. Edit a product, tick "Class pass" in the General tab, and set the number of classes and the number of valid days.
4. Go to WooCommerce > Class Passes and add your classes.
5. Create a page with the `[class_pass_schedule]` shortcode or the "Class Pass Schedule" block. Then choose it as the schedule page under WooCommerce > Class Passes > Settings.
6. Optional: create a 1-class pass product and choose it as the default drop-in product under Settings to turn on "Buy & book".

== Frequently Asked Questions ==

= Which pass is used when a member has several? =

The valid pass with the earliest expiry date. The pass must still be valid when the class starts.

= What happens when a member cancels? =

Before the cancellation deadline, the booking is cancelled and the credit goes back to the same pass. After the deadline, the member can use "Late cancel": the seat is freed but the credit stays used (unless you choose "Give it back" under Settings > Credit on late cancel). You can also turn late cancellation off; staff can always cancel from the roster.

= How do no-shows work? =

Once a class has started, open its roster and click "Mark no-show" next to the member. The credit stays used and a "No-show" line is added to the member's credit history. You can undo it from the same screen.

= How does "Buy & book" work? =

Create a simple product, tick "Class pass" and set "Classes per pass" to 1. Choose it as the default drop-in product under Settings, or per class in the class form. Members without a usable credit then see "Buy & book (price)". After payment they are booked automatically; if the class filled up first, the credit stays on their account.

= Can members add classes to their calendar? =

Yes. Each booking has an .ics download and a Google Calendar link, and My Account has a private subscribe link for Google Calendar, Apple Calendar or Outlook. Nothing is sent to a third-party service.

= Is there a limit on classes, members or bookings? =

No. The free version has no limits on classes, members, passes, bookings or history length.

= Can I sell a pass that never expires? =

Yes. Set "Valid for (days)" to 0.

= Can customers buy several passes at once? =

Yes. The credits are multiplied by the quantity in the order.

= A customer paid in cash. How do I give them credits? =

Open WooCommerce > Class Passes > Members, find the member and use "Grant a pass". Enter a reason, which is saved in the credit history.

= Does it send emails? =

WooCommerce sends its usual order emails. Booking confirmation, reminder, waitlist, expiry and low-credit emails are part of Pro.

= Does the plugin connect to external services? =

No. Everything runs on your own site. The Google Calendar link is a plain link that the member opens; no data is sent by the plugin.

== Screenshots ==

1. Weekly class schedule with balance header, booking and "Buy & book" buttons.
2. My Account > Class Passes with credits, expiry badges, upcoming bookings and calendar links.
3. Credit history in My Account.
4. Classes list under WooCommerce > Class Passes.
5. Class roster with attendance check-in and no-shows.
6. Member view with 30-day late-cancel and no-show counts, credit adjustments and history.
7. Class pass options on the product edit screen.

== Changelog ==

= 1.1.0 =
* New: Drop-in "Buy & book" — members without credit buy a 1-class pass from the schedule and are booked automatically after payment.
* New: Late-cancel and no-show policy with settings, roster no-show marking, history entries and 30-day counts.
* New: Add to calendar — .ics download (with cancellation file), Google Calendar link and a private calendar subscription per member.
* New: Credit history with typed reasons in My Account, "expires in N days" badges and a balance header on the schedule.
* New: Expired passes are recorded in the credit history and reactivated when staff set a new expiry date.
* Improved: Front-end styles follow the active theme (fonts, colours, dark themes, RTL, focus styles).
* Improved: Fewer database queries on normal page views; styles load only where the schedule or account tab is shown.
* Pro: Expiry and low-credit reminder emails with "Buy again", staff "Extend expiry", and unlimited (time-based) passes with fair-use limits.

= 1.0.0 =
* Initial release.
