function bat_options_get_option_price in Booking and Availability Management Tools for Drupal 8
Same name and namespace in other branches
- 7 modules/bat_options/bat_options.module \bat_options_get_option_price()
Calculate the price for an option.
File
- modules/
bat_options/ bat_options.module, line 142
Code
function bat_options_get_option_price($booking_price, $option, $quantity, $nights) {
$price = 0;
switch ($option['operation']) {
case BAT_OPTIONS_ADD:
$price += $option['value'];
break;
case BAT_OPTIONS_ADD_DAILY:
$price += $option['value'] * $nights;
break;
case BAT_OPTIONS_SUB:
$price -= $option['value'];
break;
case BAT_OPTIONS_SUB_DAILY:
$price -= $option['value'] * $nights;
break;
case BAT_OPTIONS_REPLACE:
$price = $option['value'] - $booking_price;
break;
case BAT_OPTIONS_INCREASE:
$price += $booking_price * $option['value'] / 100;
break;
case BAT_OPTIONS_DECREASE:
$price -= $booking_price * $option['value'] / 100;
break;
}
return $price * 100;
}