• Resolved thomasnordic

    (@thomasnordic)


    Hello again

    I finally managed to look into what we talked about 8 months ago ??

    The shortcode code you suggested works. But we struggle with findind the right form field.

    We need a list of bookings from selected calendar IDs with: (that would be perfect):
    Booking ID, date start, date end, name, total amount

    Could you help us with that?

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

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

    (@murgroland)

    Hello ??

    Please use the attached code, i’ve included the booking ID and the total amount. You’ll need to replace the ID for the “name” field with the correct one from your form.

    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;
            }
    
            $payment = wpbs_get_payment_by_booking_id($booking->get('id'));
    
            $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">'
             . $booking->get('id') . '<br>'
             . date('d.m.', strtotime($booking->get('start_date'))) . ' - '
             . date('d.m.y', strtotime($booking->get('end_date'))) . ': '
             . $name . '<br>'
             . wpbs_get_formatted_price($payment->get_total(), $payment->get_currency()) .
            '</div>';
        }
        $output .= '</div>';
        return $output;
    });
Viewing 1 replies (of 1 total)
  • The topic ‘#2 – pull data from booking database with ShortCodes or API’ is closed to new replies.