Skip to content

Instantly share code, notes, and snippets.

@kartikparmar
Created June 25, 2024 14:07
Show Gist options
  • Save kartikparmar/019cbfc9de04d9dafcc578e632bb124c to your computer and use it in GitHub Desktop.
Save kartikparmar/019cbfc9de04d9dafcc578e632bb124c to your computer and use it in GitHub Desktop.
To add additonal price on top of the calculated booking price
<?php
/**
* Add booking fee to price on product page.
*
* @param string $total_price Booking Price.
*/
function bkap_additional_booking_price( $total_price ) {
// Here you can add additional condition according to business requirements.
// This will add 15 to booking price for all the bookable product on the store.
$new_price = $total_price + 15;
return $new_price;
}
add_filter( 'bkap_modify_booking_price', 'bkap_additional_booking_price', 10, 1 );
/**
* Add booking fee to price on product page.
*
* @param string $wp_send_json Array of data to be sent in wp_send_json function.
* @param int $product_id Product ID.
*/
function bkap_show_additional_booking_price_info( $wp_send_json, $product_id ) {
// Here you can add additional condition according to business requirements.
// This will show Additional Price: $15 in the Price Box for all the bookable product on the store.
$wp_send_json['bkap_no_of_days'] = $wp_send_json['bkap_no_of_days'] . __( 'Additional Fees: ', 'woocommerce-booking' ) . wc_price( 15 ) . '<br>';
return $wp_send_json;
}
add_filter( 'bkap_final_price_json_data', 'bkap_show_additional_booking_price_info', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment