Skip to content

Instantly share code, notes, and snippets.

@erishel
Forked from cliffordp/functions.php
Last active April 8, 2019 13:37
Show Gist options
  • Save erishel/eb5cf4c142330f1f54c49de31526f540 to your computer and use it in GitHub Desktop.
Save erishel/eb5cf4c142330f1f54c49de31526f540 to your computer and use it in GitHub Desktop.

Revisions

  1. erishel revised this gist Apr 8, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -22,8 +22,8 @@ function cliff_all_tickets_default_quantity_and_readonly() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready( function () {
    // RSVP, Woo, and EDD tickets default to quantity of 1
    jQuery( 'input.tribe-ticket-quantity, .woocommerce .quantity input.qty, .edd.quantity input.edd-input' ).val( 1 ).attr( 'readonly', true );
    // RSVP, Woo, and EDD tickets default to quantity of 2
    jQuery( 'input.tribe-ticket-quantity, .woocommerce .quantity input.qty, .edd.quantity input.edd-input' ).val( 2 ).attr( 'readonly', true );

    // CSS to display RSVP tickets' "Send RSVP confirmation to" fields
    // Note: will continue to show even if user changes quantity to zero because we didn't bind to the field to continually watch it
  2. @cliffordp cliffordp revised this gist Mar 30, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@
    *
    * Same as https://gist.github.com/cliffordp/5b57df71be8b52f595817ddbf81acdab except make quantity readonly
    * Watch out if you have more than 1 ticket per event!
    *
    * ! You may want to use https://gist.github.com/cliffordp/9a457b724e38b3036f8d48adc90930ed instead!
    */
    function cliff_all_tickets_default_quantity_and_readonly() {
    // bail if not on a Single Event page
  3. @cliffordp cliffordp revised this gist Jan 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    * - Event Tickets Plus WooCommerce
    * - Event Tickets Plus Easy Digital Downloads
    *
    * From
    * From https://gist.github.com/cliffordp/80b33455779b74ec49f6ea3033cb47bf
    *
    * Same as https://gist.github.com/cliffordp/5b57df71be8b52f595817ddbf81acdab except make quantity readonly
    * Watch out if you have more than 1 ticket per event!
  4. @cliffordp cliffordp created this gist Jan 10, 2017.
    33 changes: 33 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <?php
    /**
    * Set default quantity of 1 and READONLY for all tickets:
    * - Event Tickets RSVP
    * - Event Tickets Plus WooCommerce
    * - Event Tickets Plus Easy Digital Downloads
    *
    * From
    *
    * Same as https://gist.github.com/cliffordp/5b57df71be8b52f595817ddbf81acdab except make quantity readonly
    * Watch out if you have more than 1 ticket per event!
    */
    function cliff_all_tickets_default_quantity_and_readonly() {
    // bail if not on a Single Event page
    if ( ! function_exists( 'tribe_is_event' ) || ! tribe_is_event() ) {
    return false;
    }

    wp_enqueue_script( 'jquery' );
    ?>
    <script type="text/javascript">
    jQuery(document).ready( function () {
    // RSVP, Woo, and EDD tickets default to quantity of 1
    jQuery( 'input.tribe-ticket-quantity, .woocommerce .quantity input.qty, .edd.quantity input.edd-input' ).val( 1 ).attr( 'readonly', true );

    // CSS to display RSVP tickets' "Send RSVP confirmation to" fields
    // Note: will continue to show even if user changes quantity to zero because we didn't bind to the field to continually watch it
    jQuery( 'tr.tribe-tickets-meta-row' ).show();
    });
    </script>
    <?php
    }
    add_action( 'wp_footer', 'cliff_all_tickets_default_quantity_and_readonly' );