Limiting the number of entries – two date in one form

Home Forums Quform WordPress Limiting the number of entries – two date in one form

This topic is: not resolved
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32029
    Dixx37
    Participant

    Hello ๐Ÿ™‚

    I use the form to register for events. Sometimes it happens that one event has two dates. I would like to set the limit of registrations separately for one date and for the other one (I choose “select menu” to enter the date).

    Event name
    Date:
    (Select menu)
    22.10.2020 – max 10 entries
    28.10.2020 – max 10 entries

    when i use this:

    Limiting the number of entries

    i set 10 entries for all date. Then there can be 5 records for one date and 15 records for the other date. ๐Ÿ™

    Some time i have 8 date in one form, so i must create 8 form ๐Ÿ™

    #32042
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #32044
    Dixx37
    Participant

    It’s great!
    Thank you very much

    I have two questions:

    1) Is it possible to make the date, which is full, disappear from the selection choice?

    When 22.10.2020 it’s full, people don’t see this date in form.

    2. is it possible to display somewhere (as an admin – in the back or in the entry) how many slots are left for each date?

    • This reply was modified 4 years, 1 month ago by Dixx37.
    #32049
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #36440
    janheu
    Participant

    Hi, Iยดm coming back to this post since I have a similar idea.
    We have multiple Dates set in a option field. Based on a selection made before,

    First the user selects a place via dropdown -> afterwards he/she can select a date (option) based on that selection.

    add_action('quform_pre_display_33', function (Quform_Form $form) {
    global $wpdb;
    $query = "SELECT COUNT(*)
    FROM {$wpdb->prefix}quform_entry_data ed
    LEFT JOIN {$wpdb->prefix}quform_entries e
    ON ed.entry_id = e.id
    WHERE e.form_id = %d AND ed.element_id = %d AND ed.value = %s";

    // Erstes Radio-Button-Element
    $uniqueId1 = '33_32';
    $limits1 = array(
    '03.02.2024' => 6,
    '24.02.2024' => 6,
    );
    updateRadioOptions($form, $uniqueId1, $limits1, $wpdb, $query);

    // Zweites Radio-Button-Element
    $uniqueId2 = '33_33';
    $limits2 = array(
    '09.02.2024' => 6,
    '17.02.2024' => 6,
    );
    updateRadioOptions($form, $uniqueId2, $limits2, $wpdb, $query);
    });

    function updateRadioOptions($form, $uniqueId, $limits, $wpdb, $query) {
    $radio = $form->getElement('quform_' . $uniqueId);
    if ($radio instanceof Quform_Element_Radio) {
    $options = array();
    foreach ($radio->getOptions() as $option) {
    $value = isset($option['value']) ? $option['value'] : null;
    if ($value && array_key_exists($value, $limits)) {
    $count = $wpdb->get_var($wpdb->prepare($query, $form->getId(), $radio->getId(), $value));
    if ($count < $limits[$value]) {
    $options[] = $option;
    }
    } else {
    $options[] = $option;
    }
    }
    $radio->setOptions($options);
    }
    }

    Thats the idea, somehow it doesnt seem to work, any idea how we can adjust it?
    Is there a way to display a message if all spots for this place are already booked?
    thanks a lot

    #36441
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Be inspired. ยฉ 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy