Skip to content

Instantly share code, notes, and snippets.

View kartikparmar's full-sized avatar

Kartik Parmar kartikparmar

  • Mumbai
View GitHub Profile
@kartikparmar
kartikparmar / functions.php
Created October 14, 2024 05:59
To show the error notice before the booking form
<?php
// Function to enqueue the custom script to move WooCommerce Error Notices
function bkap_move_woocommerce_notices_above_booking_form() {
if ( is_product() ) {
?>
<script>
jQuery(document).ready(function($) {
var wooNotices = $('.woocommerce-error');
if ( wooNotices.length && $('.bkap-booking-form').length ) {
@kartikparmar
kartikparmar / functions.php
Created September 24, 2024 12:08
Change calendar icon
/**
* This function will change the calendar icon of the Date selection fields in the front-end booking form.
*/
function bkap_calendar_custom_icon_file() {
return 'https://www.pngfind.com/pngs/m/681-6816950_small-calendar-icon-png-transparent-png.png';
}
add_filter( 'bkap_calendar_icon_file', 'bkap_calendar_custom_icon_file' );
@kartikparmar
kartikparmar / functions.php
Created September 24, 2024 10:04
Change subscription price.
<?php
function update_subscription_with_original_price( $subscription_id, $args ) {
global $wpdb;
// Get the download ID from the $args array
$download_id = $args['product_id'];
// Get the price ID if variable pricing is used
$price_id = ! empty( $args['price_id'] ) ? $args['price_id'] : null;
@kartikparmar
kartikparmar / functions.php
Created August 13, 2024 21:30
Allow booking on disabled weekdays, in advance booking period, also ignore the manage time availability settings on backend
<?php
/**
* This function will not ignore the Advance Booking Period settings on Backend.
*/
function bkap_advance_booking_period_callback( $abp ) {
return is_admin() ? 0 : $abp;
}
add_filter( 'bkap_advance_booking_period', 'bkap_advance_booking_period_callback', 10, 1 );
@kartikparmar
kartikparmar / functions.php
Last active August 12, 2024 04:40
Cosnider booking price as zero for particular products
<?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 ) ) {
@kartikparmar
kartikparmar / functions.php
Created June 28, 2024 12:44
Fetch bookings for given product id and available comment data.
<?php
$args = array(
'post_type' => 'bkap_booking', // Replace with your actual custom post type
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_bkap_product_id',
'value' => '123',
'compare' => '='
@kartikparmar
kartikparmar / functions.php
Created June 25, 2024 14:07
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.
@kartikparmar
kartikparmar / functions.php
Created April 26, 2024 13:31
Adding Email Address on the View Booking Page, CSV and Print.
<?php
/* Tyche Softwares: addon they gave me July 2022 to add an email column to the View Bookings page */
/* Adding Column on View Bookings */
function bkap_view_booking_columns( $columns ) {
$additional_columns = array( 'bkap_customer_email' => __( 'Email Address', 'woocommerce-booking' ) );
// Adding column after Booked by hence 5.
$columns = array_slice( $columns, 0, 5, true ) + $additional_columns + array_slice( $columns, 5, count( $columns ) - 5, true );
@kartikparmar
kartikparmar / functions.php
Created December 27, 2023 10:57
Adding fees, delivery and address information to view bookings page, csv, print
<?php
/* Adding Column on View Bookings */
function bkap_view_booking_columns( $columns ) {
$additional_columns = array( 'bkap_invoice' => __( 'Invoice', 'woocommerce-booking' ), 'bkap_delivery' => __( 'Delivery', 'woocommerce-booking' ), 'bkap_customer_address' => __( 'Customer Address', 'woocommerce-booking' ) );
// Adding column after Booked by hence 5.
$columns = array_slice( $columns, 0, 5, true ) + $additional_columns + array_slice( $columns, 5, count( $columns ) - 5, true );
@kartikparmar
kartikparmar / functions.php
Last active December 14, 2023 11:43
dequeue jquery script
<?php
function dequeue_jquery_scripts() {
wp_dequeue_script( 'jquery' );
wp_dequeue_script( 'jquery-ui' );
wp_dequeue_script( 'jquery-ui-datepicker' );
}
add_action( 'wp_enqueue_scripts', 'dequeue_jquery_scripts', 100 );