Last active
August 12, 2024 04:40
-
-
Save kartikparmar/540af735f8d46b5a14afeebd28c755ff to your computer and use it in GitHub Desktop.
Cosnider booking price as zero for particular products
This file contains hidden or 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 | |
/** | |
* This function consider the booking price as 0 for the particular product. | |
*/ | |
function bkap_modify_booking_price_to_zero( $time_slot_price, $product_id, $variation_id, $product_type ) { | |
$products_to_consider_price_as_zero = array( '18290', '1234' ); | |
if ( in_array( $product_id, $products_to_consider_price_as_zero ) ) { | |
return 0; | |
} | |
return $time_slot_price; | |
} | |
add_filter( 'bkap_modify_booking_price', 'bkap_modify_booking_price_to_zero', 10, 4 ); | |
/** | |
* This function will add css to hide the pricing in the booking table. | |
*/ | |
function bkap_add_custom_inline_css() { | |
if ( is_product() ) { | |
$product_id = get_the_ID(); | |
$products_to_consider_price_as_zero = array( '18290', '1234' ); | |
if ( in_array( $product_id, $products_to_consider_price_as_zero ) ) { // Use 'special-page' if using the page slug or '123' if using the page ID | |
?> | |
<style> | |
/* Inline CSS for the specific page */ | |
#bkap-multidate-info td:nth-of-type(3) { | |
display: none; | |
} | |
div#bkap-price-box { | |
display: none !important; | |
} | |
#bkap-multidates-total-tr{ | |
display: none; | |
} | |
</style> | |
<?php | |
} | |
} | |
} | |
add_action( 'wp_head', 'bkap_add_custom_inline_css' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment