示例#1
0
function est_action_get_booking_prices()
{
    $currency = get_post_meta($_POST['_est_property_id'], '_est_rent_currency', true);
    $currency_position = get_post_meta($_POST['_est_property_id'], '_est_rent_currency_position', true);
    $_POST['_est_guests'] = empty($_POST['_est_guests']) ? 1 : $_POST['_est_guests'];
    if (empty($_POST['_est_end']) or empty($_POST['_est_start'])) {
        $response['price_per_night'] = est_get_amount(0, $currency, $currency_position);
        $response['total_price'] = est_get_amount(0, $currency, $currency_position);
    } else {
        $booking = new BonsaiBooking($_POST['_est_property_id'], $_POST['_est_guests'], $_POST['_est_start'], $_POST['_est_end']);
        $response['price_per_night'] = est_get_amount($booking->calculatePricePerNight(), $currency, $currency_position);
        $response['total_price'] = est_get_amount($booking->calculateTotalPrice(), $currency, $currency_position);
    }
    echo json_encode($response);
    die;
}