Okay
  Public Ticket #2124842
When event is more then 1 day all dates are clickable
Closed

Comments

  •  1
    Daniel started the conversation

    We have events that are more then one day, its not possible to join the event for the 1 of 2 days but a ticket grands access to all days. Is it possible to hide the data's accept the starting date?

  •  877
    Zhivko replied

    I've recently wrote such filters.

    Open your theme functions.php file and place one of following examples.

    Example 1:

    This code preselects the values and hides all dates except the event start date.

    /**
     * STEC Custom func
     * Booking preselected values
     */
    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {
                function preselectBookingValues(m) {
                    // Run last
                    setTimeout(function () {
                        var $ticketSelector = m.$instance.find('select[name="stec_book_item"]');
                        var $dateSelector = m.$instance.find('select[name="stec_book_date"]');
                        var $ticketNumber = m.$instance.find('input[name="stec_book_quantity"]');
                        
                        // Only 1 date preselected
                        $dateSelector.find('option').not(':eq(1)').remove();
                        
                        // Preselect ticket if only one available
                        if ($ticketSelector.children().length <= 2) {
                            $ticketSelector.children().last().prop('selected',true);
                        }
                        
                        // Preselect quantity to 1
                        $ticketNumber.val(1);
                    }, 0);
                }
                
                // Calendar event inner
                $('.stec').on('onEventToggleOpen', function (e, m) {
                    preselectBookingValues(m);
                });
                // Single event pages
                if (typeof window.stecSingleEvent !== 'undefined') {
                    preselectBookingValues({
                        $instance: $('.stec-layout-single')
                    });
                }
            })(jQuery);
        </script>
        <?php
    }, 9999);


    Example 2:

    This code disables the date selector entirely.

    /**
     * STEC Custom func
     * Disable booking date selector
     */
    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {
                
                // Disable func
                function disableDateSelector(m) {
                    
                    var textReplace = 'All dates'; // can be anything
                    
                    var $dateSelector = m.$instance.find('select[name="stec_book_date"]');
                    
                    $dateSelector.children(':selected').text(textReplace);
                    
                    $dateSelector
                            .css('opacity', 0.5)
                            .prop('disabled', true);
                }
                // Disable for calendar event inner
                $('.stec').on('onEventToggleOpen', function (e, m) {
                    disableDateSelector(m);
                });
                
                // Disable for single event pages
                if (typeof window.stecSingleEvent !== 'undefined') {
                    disableDateSelector({
                        $instance: $('.stec-layout-single')
                    });
                }
            })(jQuery);
        </script>
        <?php
    }, 9999);



    Stachethemes Developer