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

feat: Custom ticket field types and queries implemented. #40

Merged

Conversation

kidunot89
Copy link
Collaborator

@kidunot89 kidunot89 commented Feb 1, 2022

Summary

  • Implements Query for One Off Ticket Fieldsets #35
  • Implements Query for Saved Custom Ticket Fieldsets #34
  • Adds TicketField Interface to schema
  • Adds the following TicketField child object type
    • TicketFieldBirthdate
    • TicketFieldCheckbox
    • TicketFieldDate
    • TicketFieldDropdown
    • TicketFieldEmail
    • TicketFieldPhone
    • TicketFieldRadio
    • TicketFieldText
    • TicketFieldURL
  • Adds the ticketFields field to the Product type
    Example Query
{
  events {
    nodes {
      wooTickets {
        nodes {
          name
          ticketFields {
            type
            label
            description
            required
            ... on TicketFieldCheckbox {
              options
            }
            ... on TicketFieldDropdown {
              options
            }
            ... on TicketFieldEmail {
              placeholder
            }
            ... on TicketFieldPhone {
              placeholder
            }
            ... on TicketFieldRadio {
              options
            }
            ... on TicketFieldText {
              placeholder
            }
            ... on TicketFieldURL {
              placeholder
            }
          }
        }
      }
    }
  }
}
  • Adds the ticketFields field to the Event
    Example Query
{
  events {
    nodes {
      ticketFields {
        type
        label
        description
        required
        ... on TicketFieldCheckbox {
          options
        }
        ... on TicketFieldDropdown {
          options
        }
        ... on TicketFieldEmail {
          placeholder
        }
        ... on TicketFieldPhone {
          placeholder
        }
        ... on TicketFieldRadio {
          options
        }
        ... on TicketFieldText {
          placeholder
        }
        ... on TicketFieldURL {
          placeholder
        }
      }
    }
  }
}

TODO

  • Add Event -> ticketFields unit test
  • Add Product -> ticketFields unit test

Copy link
Member

@borkweb borkweb left a comment

Choose a reason for hiding this comment

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

This is looking pretty great! Just a couple of minor tweaks.

Comment on lines 49 to 61
\WPGraphQL\QL_Events\Type\WPInterface\Ticket_Field::register_type();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Birthdate::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Checkbox::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Date::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Dropdown::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Email::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Phone::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Radio::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Text::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\URL::register();
Copy link
Member

Choose a reason for hiding this comment

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

We could simplify this down to the following, due to the namespace at the top of the file:

Suggested change
\WPGraphQL\QL_Events\Type\WPInterface\Ticket_Field::register_type();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Birthdate::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Checkbox::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Date::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Dropdown::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Email::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Phone::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Radio::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Text::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\URL::register();
Type\WPInterface\Ticket_Field::register_type();
Type\WPObject\Ticket_Field\Birthdate::register();
Type\WPObject\Ticket_Field\Checkbox::register();
Type\WPObject\Ticket_Field\Date::register();
Type\WPObject\Ticket_Field\Dropdown::register();
Type\WPObject\Ticket_Field\Email::register();
Type\WPObject\Ticket_Field\Phone::register();
Type\WPObject\Ticket_Field\Radio::register();
Type\WPObject\Ticket_Field\Text::register();
Type\WPObject\Ticket_Field\URL::register();

Copy link
Member

Choose a reason for hiding this comment

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

Or even add use WPGraphQL\QL_Events\Type\WPObject\Ticket_Field; at the top then change to:

Suggested change
\WPGraphQL\QL_Events\Type\WPInterface\Ticket_Field::register_type();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Birthdate::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Checkbox::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Date::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Dropdown::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Email::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Phone::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Radio::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\Text::register();
\WPGraphQL\QL_Events\Type\WPObject\Ticket_Field\URL::register();
Ticket_Field::register_type();
Ticket_Field\Birthdate::register();
Ticket_Field\Checkbox::register();
Ticket_Field\Date::register();
Ticket_Field\Dropdown::register();
Ticket_Field\Email::register();
Ticket_Field\Phone::register();
Ticket_Field\Radio::register();
Ticket_Field\Text::register();
Ticket_Field\URL::register();

public static function register_type() {
register_graphql_interface_type(
'TicketField',
array(
Copy link
Member

Choose a reason for hiding this comment

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

Can we switch to short array syntax? [] rather than array()?

$fieldsets = tribe( 'tickets-plus.meta' )->meta_fieldset()->get_fieldsets();

foreach( $fieldsets as $fieldset ) {
print_r( $fieldset );
Copy link
Member

Choose a reason for hiding this comment

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

Remove this debug line. 🕺

Comment on lines 31 to 36
// 'test' => array(
// 'type' => 'String',
// 'resolve' => function() use( $fieldset ) {
// return wp_json_encode( $fieldset );
// }
// )
Copy link
Member

Choose a reason for hiding this comment

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

Remove?

@kidunot89 kidunot89 force-pushed the feat/tickets-custom-field-types branch from aa7def8 to 262406f Compare April 26, 2022 22:13
@kidunot89 kidunot89 force-pushed the feat/tickets-custom-field-types branch from 0bf4df9 to 7b054de Compare August 29, 2022 18:24
@kidunot89 kidunot89 marked this pull request as ready for review August 29, 2022 18:34
@kidunot89 kidunot89 added enhancement New feature or request new type PR implements a new type new fields PR implements a new type field(s) labels Sep 1, 2022
@borkweb borkweb merged commit 1386c73 into the-events-calendar:master Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new fields PR implements a new type field(s) new type PR implements a new type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants