Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CampTix: Add "Remote" ticket type #386

Merged
merged 14 commits into from
Mar 16, 2020
Merged

Conversation

ryelle
Copy link
Contributor

@ryelle ryelle commented Mar 11, 2020

Set up a "Ticket Type", which pulls from a global list of types (set up in code) and can conditionally alter the registration process. Types are set up as a safelist of slug+name, and the type is saved in ticket post meta. This also updates the allergy & accommodations questions, by adding filters to skip rendering the question and/or reword the question text. Other ticket types are possible in the future, by filtering camptix_ticket_types & similarly working with CampTix filters.

Fixes #385

👩🏼‍💻 Dev notes…

I went through 2 architecture iterations before landing here— intentionally not using the CampTix_Addon class & instead sticking to plain namespacing so that the ticket-type files can easily access the get_type* functions. This way, we can add another file to ticket-types, ex workshop.php, and just like remote.php set it up to filter camptix_ticket_types. I tried to make minimal changes to CampTix itself & the hardcoded questions. Overall this works pretty well but I'd still be interested in any feedback.

📝 I could use copy advice!

You can see these strings "in context" in the screenshots below, but I'd appreciate better phrasing or even re-worked ideas.

  • Ticket type name: I went with "Default" & "Remote/Livestream"
  • Describing what the ticket types are:
    The type of ticket will determine how we set up the required questions. This
    cannot be changed once someone buys a ticket.
    
    Default: Default, in-person attendee.
    Remote/Livestream: Remote attendee, ex: watching on livestream, from home.
    
  • Reworded a11y question: "Do you have any accessibility needs, such as a sign language interpreter, to participate in WordCamp?" — this is still hard-coded, but there was a request that it be re-worded to be more remote-friendly, so I removed the "wheelchair access" bit.

Screenshots

Creating a new ticket type allows for picking a type
c-default-dd

Once a ticket is purchased, this is disabled
Screen Shot 2020-03-11 at 4 35 21 PM

The ticket type is added to the ticket list table
c-ticket-list

In the ticket form, we don't ask the allergy question, and the accommodations question is updated.
c-remote-ticket-form

How to test the changes in this Pull Request:

  1. Create a ticket, pick "Remote" for the type
  2. It should work, and be labelled "remote" in the list table in wp-admin
  3. Go through buying a remote ticket
  4. The allergy question should not be in the form
  5. The a11y question should not say anything about physical access
  6. Selecting yes for the a11y question should still trigger the email
  7. Buy a non-remote ticket
  8. Allergy & a11y questions are both present
  9. Selecting yes for the allergy question should still trigger the email

@ryelle ryelle changed the title Add/camptix ticket types CampTix: Add "Remote" ticket type Mar 11, 2020
Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@coreymckrill coreymckrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Tested locally.

Some comments, but no blockers.

Comment on lines 56 to 62
function get_slug_from_value( $value ) {
$match = wp_list_pluck( wp_list_filter( get_types(), array( 'slug' => $value ) ), 'slug' );
if ( count( $match ) > 0 ) {
return current( $match );
}
return 'default';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the types were registered as an associative array, with the slug as the key? Then this function might be simpler or even unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea — less magic with wp_list_* 🙂

Comment on lines 154 to 164
if ( ! isset( $_POST['action'] ) || 'editpost' != $_POST['action'] ) {
return;
}

// Security check.
$nonce_action = 'update-post_' . $post_id;
check_admin_referer( $nonce_action );

if ( isset( $_POST['tix_type'] ) ) {
update_post_meta( $post_id, META_KEY, $_POST['tix_type'] );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using filter_input() here (everywhere) to retrieve the $_POST values, instead of referencing them directly. It gives you some built-in validation and sanitizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitization callback in register_post_meta takes care of this, but just to be extra-sure I added it.

@timiwahalahti
Copy link
Collaborator

For me, copy looks good.

@melchoyce
Copy link

Ticket type name: I went with "Default" & "Remote/Livestream"

I'd probably go with either one, or the other. I think "Livestream" is likely more common here, so I'd recommend just using that work as the ticket label.

@ryelle ryelle merged commit ccf415b into production Mar 16, 2020
@ryelle ryelle deleted the add/camptix-ticket-types branch March 16, 2020 18:03
@CdrMarks
Copy link
Collaborator

@ryelle I saw you said in #community-events on Slack the Livestream ticket type was available. I tested on my local environment and see the new feature related to ccf415b. I checked the 2020 Birmingham site where I'm an organizer and I do not see this feature available.

@ryelle
Copy link
Contributor Author

ryelle commented Mar 17, 2020

@CdrMarks It was my mistake— I left the "don't enable this on production" flag in. It's now available for all sites.

@ryelle ryelle added this to the COVID-19 Response milestone Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] CampTix Including addons
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CampTix: Add "remote" ticket type, update required question
6 participants