Skip to content

feat: event page shows the basket; changing it adds or removes attendees - #13

Merged
crazeydave merged 1 commit into
mainfrom
feat/event-form-shows-basket
Nov 19, 2026
Merged

crazeydave merged 1 commit into
mainfrom
feat/event-form-shows-basket

Conversation

@crazeydave

Copy link
Copy Markdown
Contributor

The journey: on the event page press add twice, then Get tickets, which goes to attendee information. Go back to the event page and the form now shows 2. Changing the numbers and pressing Get tickets again adds or removes attendees on the attendee information page, without losing anything already entered.

Event page (assets/js/basket.js, views/tickets-form-fields.php)

  • After the page loads, the form asks for this event's basket (admin-ajax.php?action=tsharp_basket; event pages are often cached, so it can't be in the HTML), fills in the quantities and shows Event Tickets' own "tickets already in your cart" notice. It asks again when the page is restored by the Back button.
  • Then it marks the form tsharp_basket=1. Until the answer arrives, or if it fails, the form adds as it always has, so a form still showing 0 can never empty a basket.

Get tickets (CartHandler)

  • With tsharp_basket=1 the posted quantities replace the basket's for that event: more adds attendees, fewer leaves the last ones out, 0 removes the ticket. A rise goes through woocommerce_update_cart_validation, so capacity holds. The buyer then goes to attendee information when any ticket asks for it, otherwise to checkout; with nothing of the event left, back to the event page.
  • New action tickets_sharp/basket_changed.

Attendee details are never lost (DetailsPage)

  • Answers beyond a line's quantity stay on the cart line; they're not copied to the order or listed in the basket, and come back if the quantity goes up.
  • A ticket taken out of the basket (any route) has its answers set aside in the WooCommerce session and restored when it's added again. woocommerce_cart_emptied (checkout) clears them.

Checks. Local gates (ci-local tickets-sharp, PHP 8.4) pass: 309 tests, PHPStan, PHPCS. Not yet tried in a browser on a site with WooCommerce; staging63 is next.

Known limit. Event Tickets disables Get tickets when every quantity is 0, so the whole basket can't be emptied from the event page; the basket page still does that.

Merging releases a minor version (0.6.0).

Back on the event page, the "Get tickets" form now shows the tickets
already in the basket for that event, with Event Tickets' own "already in
your cart" notice. assets/js/basket.js fetches them through admin-ajax
(tsharp_basket) after the page loads, since event pages are often cached.

A form filled that way posts tsharp_basket=1, and CartHandler then sets the
basket's quantities to the posted ones instead of adding them: more adds
attendees, fewer leaves the last ones out, zero removes the ticket, and a
rise goes through WooCommerce's update-cart validation so capacity holds.
The buyer goes on to the attendee details page. Until the basket has been
fetched, the form adds as before, so it can never empty a basket by mistake.

Attendee details already entered are never lost: answers beyond the
quantity stay on the cart line (not copied to the order or shown in the
basket), and a ticket taken out of the basket has its answers set aside in
the WooCommerce session and restored if it is added again. Checkout clears
them.
@crazeydave
crazeydave merged commit 91f9b45 into main Nov 19, 2026
5 checks passed
@crazeydave
crazeydave deleted the feat/event-form-shows-basket branch November 19, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant