This example uses custom PHP code to implement more complex booking logic.
Source code for this form:
<label>Check in [date checkin] </label> <label>Check out [date checkout] </label> [calculate_button calculate_button-1 "Calculate"] Price estimate: <span id="booking_total">$ [calculation price min:0 "fn_php( use PVBCF7CalculatorPro\lib\PVBCF7Calculator; $prices = array( array('start' => '01-01', 'end' => '02-10', 'price' => '10'), array('start' => '02-11', 'end' => '03-20', 'price' => '11'), array('start' => '03-21', 'end' => '04-30', 'price' => '12'), array('start' => '05-01', 'end' => '06-10', 'price' => '13'), array('start' => '06-11', 'end' => '07-20', 'price' => '14'), array('start' => '07-21', 'end' => '08-31', 'price' => '15'), array('start' => '09-01', 'end' => '10-10', 'price' => '16'), array('start' => '10-11', 'end' => '11-20', 'price' => '17'), array('start' => '11-20', 'end' => '12-31', 'price' => '18') ); $booking_start = PVBCF7Calculator::arrayValue($_POST, 'checkin'); $booking_end = PVBCF7Calculator::arrayValue($_POST, 'checkout'); if (empty($booking_start) or empty($booking_end) or strtotime($booking_start) > strtotime($booking_end)) { return 0; /* Invalid dates */ } $total = 0; for ($i = strtotime($booking_start); $i <= strtotime($booking_end)-86400; $i += 86400) { $year = date('Y', $i); $processed_prices = array(); foreach ($prices as $p) { if ($i >= strtotime($year . '-' . PVBCF7Calculator::arrayValue($p, 'start')) && $i <= strtotime($year . '-' . PVBCF7Calculator::arrayValue($p, 'end')) ) { $total += PVBCF7Calculator::arrayValue($p, 'price'); } } } return $total; )"]</span>