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 September 20, 2022 04:21
Sending Booking Confirmation Email After the Order Receieved - Product setup without confirmtion.
<?php
/**
* This will send the Booking Confirmation email to customer even if the product is not setup with the requires confirmation option.
*
* @param int $order_id Order Id.
*/
function bkap_send_booking_confirmation( $order_id ) {
if ( ! $order_id )
@kartikparmar
kartikparmar / functions.php
Last active September 15, 2022 08:00
Adding custom item data to order when order is placed for the bookable product.
<?php
/**
* Adding custom data to item when booking order is placed.
*
* @param int $item_id Item ID.
* @param int $product_id Product ID.
* @param array $booking_data Booking data.
*/
function bkap_update_item_meta( $item_id, $product_id, $booking_data ) {
@kartikparmar
kartikparmar / functions.php
Created July 28, 2022 18:38
Hide Booking Meta Box on the wcfm product page.
<?php
add_action( 'after_wcfm_products_manage', function( $product_id ) {
?>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
function bkap_hide_booking_metabox() {
let product_type = $( '#product_type' ).val();
let allowed_type = [ 'simple'/* , 'variable', 'subscription','variable-subscription' */ ];
if ( jQuery.inArray( product_type, allowed_type ) == -1 ) {
@kartikparmar
kartikparmar / functions.php
Created July 22, 2022 12:04
Adding Email Address Column on View Bookings, CSV, Print
<?php
/* 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 July 8, 2022 05:51
Show timeslot note in the dropdown
<?php
/**
* This function will add the note information to its respective timeslots.
*
* @param array $time_drop_down_array Array of timeslots and its lockout. Key will be timeslot and it contains array with has lockout information.
* @param array $extra_information Additional Informations.
* @since 1.0
*/
function bkap_time_slot_filter( $time_drop_down_array, $extra_information ) {
@kartikparmar
kartikparmar / functions.php
Created June 9, 2022 11:58
Adding Special Price to Variable Price
<?php
/**
* Adding Special Price to Variable Price.
*
* @param string $time_slot_price Booking Price.
* @param string $product_id Product ID.
* @param string $variation_id Variable ID.
* @param string $product_type Product type.
*
<?php
function bkap_load_defaults(){
?>
<script>
jQuery( document ).ready( function ( $ ) {
if ( jQuery('#bkap-booking-type' ).length > 0 ) {
// Enable Booking.
jQuery( '#booking_enable_date' ).prop( 'checked', true );
@kartikparmar
kartikparmar / functions.php
Created May 30, 2022 09:42
Enable Booking Option and Inline Calendar on front end.
<?php
function bkap_booking_default_settings() {
?>
<script>
jQuery( document ).ready( function ( $ ) {
if ( jQuery('#bkap-booking-type' ).length > 0 ) {
// Enable Booking.
jQuery('#booking_enable_date').prop( 'checked', true );
<?php
function limit_booking_types( $booking_types ) {
if ( is_admin() ) {
return $booking_types;
}
$booking_types = array(); // Clear previous contents of variable.
$group_only_days = 'Only Days';
@kartikparmar
kartikparmar / functions.php
Created April 11, 2022 05:12
Adding Base Cost to the Booking Price.
<?php
// Display Fields
function woocommerce_product_base_cost_fields() {
global $woocommerce, $post;
echo '<div class="product_custom_field">';
// Custom Product Number Field.
woocommerce_wp_text_input(