Sometimes for booking services, you might need to change the pricing of bookings for promotional reasons or change prices for seasonal booking products. In this post, we will see how to control the pricing logic when using the Booking and Appointment plugin for WooCommerce.
Imagine an online banquet hall booking service that allows customers to book any number of hours at their convenience but for a fixed rate. In such a scenario, regardless of how many hours the customer selects, the code will always apply a fixed 1-hour rate as the booking cost.
Solution: Set Fixed Booking Cost to 1 Hour Duration in WooCommerce Booking and Appointment Plugin
The below code snippet will customize the pricing logic in the WooCommerce Booking and Appointment Plugin to always calculate the booking price based on a duration of 1-hour rate only, without considering the actual duration booked by the customer.
/** * Always calculate the price for according to 1 duration * * @param int $duration Selected Duration by customer * * @return array */ function bkap_fixed_duration_price_callback( $duration ) { $duration = 1; // Price will be always calculated according to 1 duration even if the customer has chosen any duration. return $duration; } add_filter( 'bkap_fixed_duration_price', 'bkap_fixed_duration_price_callback', 10, 1 );
Output
When a customer books a banquet hall during an unseasonal time, the booking price is fixed to a 1-hour rate, no matter how many hours the customer selects.
Alternatively, you can also display a customized pricing model based on the duration selected by the customer. This way you can offer different pricing strategies for different products that align with customer preferences.