Support

Account

Home Forums Add-ons Repeater Field Show field x if field y contains… Reply To: Show field x if field y contains…

  • Hi John
    I’ve explained my problem badly I think.

    The user can only choose a checkin and a checkout date and press ‘submit’.

    PropertyA uses BookingSiteA
    PropertyB uses BookingSiteB
    both have different syntax for selecting dates

    The user selects dates then the dates are input into a link ($bookingfield)
    on SUBMIT they are sent to that URL.

    So if the use is on PropertyA the syntax is
    http://booking.com?checkin=1/1/18:checkout=3/1/18

    If the user is on PropertyB the syntax is
    http://ezyrez.com?in=1/1/18for2nights

    PropertyA and PropertyB booking links are managed from the backend – the user can’t touch them – they’re set.

    So what I’m trying to do is find a flexible way of checking what is contained in the booking link field and depending on the result, compiling the URL in a different way.

    I’ve only given 2 examples of link syntax for simplicity, i’d like to be able to cover 7 or 8 different possibilities in an IF ELSEIF ELSE statement.

    This is the current code, that ONLY goes to booking.com

    <?php
    $linkout = get_field('accom_booking_link');
    $datein = (isset($_GET['checkin']) ? $_GET['checkin'] : null);
    $dateout = (isset($_GET['checkout']) ? $_GET['checkout'] : null);
    ?>
    
    <?php if (strpos($linkout, 'booking') !== false){ ?>
    <form id="datepick" method="GET" action="<?php echo $linkout . ';checkin=' . $datein . ';checkout=' . $dateout . ';' ?>">
    <h2>Availability</h2>
    <ul>
        <li><label>Check In </label><input type="text" id="checkin" name="checkin" value=""/></li>
        <li><label>Check Out </label><input type="text" id="checkout" name="checkout" value="" /></li>
        <li class="submit"><input type="submit" onClick="ga('send', 'event', 'BookingCom', 'availabiliity', '<?php echo $name; ?>' );"></li>
    </ul> 
    </form>
    <?php }
    ?>