Last active
June 19, 2018 22:46
-
-
Save DevWael/d64e77c77324762c8315ed9e05f78011 to your computer and use it in GitHub Desktop.
Add additional cost to Woocommerce booking cost during price calculation depending Persons Count and on ACF Meta Box Result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'booking_form_calculated_booking_cost', 'prefix_calculate_prices_based_on_cars_count', 10, 3 ); | |
function prefix_calculate_prices_based_on_cars_count( $cost, $book_obj, $posted ) { | |
$additional_cost = 198.6; //Change Cost Here | |
if ( 'public-tour' == get_field( 'oks-tour-type', $book_obj->product->id ) ) { | |
if ( $posted['wc_bookings_field_persons'] >= 1 && $posted['wc_bookings_field_persons'] <= 5 ) { | |
return $cost + $additional_cost; | |
} elseif ( $posted['wc_bookings_field_persons'] >= 6 && $posted['wc_bookings_field_persons'] <= 10 ) { | |
return $cost + ( $additional_cost * 2 ); | |
} elseif ( $posted['wc_bookings_field_persons'] >= 11 && $posted['wc_bookings_field_persons'] <= 15 ) { | |
return $cost + ( $additional_cost * 3 ); | |
} elseif ( $posted['wc_bookings_field_persons'] >= 16 && $posted['wc_bookings_field_persons'] <= 20 ) { | |
return $cost + ( $additional_cost * 4 ); | |
} else { | |
return $cost; | |
} | |
} else { | |
return $cost; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment