• Resolved thomasnordic

    (@thomasnordic)


    Hello! Always fantastic support. We have our http://www.risoya.no site up and running. Recieving bookings. Syncing with Airbnb.

    Is there a way to pull data from the database with bookings and display on a page (password protected). I want to create a simple overview for cleaning lists, numbers of towels needed, moving in moving out and more.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Roland Murg

    (@murgroland)

    Hey @thomasnordic,

    You can add the code below to your theme’s functions.php file. It will create a shortcode that you can add on any page to display future bookings. You can also include details such form data by searching for a field’s value.

    add_shortcode('wpbs-bookings', function ($atts, $content = null) {
        $bookings = wpbs_get_bookings(array('calendar_id' => $atts['calendar_id'], 'orderby' => 'start_date', 'order' => 'asc'));
        $output = '<div class="wpbs-custom-bookings">';
        foreach ($bookings as $booking) {
            if (strtotime($booking->get('start_date')) < current_time('timestamp')) {
                continue;
            }
    
            $fields = $booking->get('fields');
    
            $name = $fields[array_search('155', array_column($fields, 'id'))]['user_value']; // 155 is the form field ID for the "name" field.
    
            $output .= '<div class="wpbs-custom-booking">'
             . date('d.m.', strtotime($booking->get('start_date'))) . ' - '
             . date('d.m.y', strtotime($booking->get('end_date'))) . ': '
             . $name .
            '</div>';
        }
        $output .= '</div>';
        return $output;
    });
    Thread Starter thomasnordic

    (@thomasnordic)

    Thank you. I will need my IT friend to help me with that. Testing soon.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘pull data from booking database with ShortCodes or API’ is closed to new replies.