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 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(
@kartikparmar
kartikparmar / functions.php
Created January 28, 2022 12:01
Showing Full Payment information in the Pricing Box
<?php
function bkap_appending_additional_information_to_price( $display_price, $data ) {
if ( isset( $data['total_price_calculated'] ) ) {
$label = __( 'Full Payment: ', 'woocommerce-booking' );
$full_price = $label . wc_price( $data['total_price_calculated'] ) . '</br>';
$display_price = $full_price . $display_price;
}
@kartikparmar
kartikparmar / functions.php
Created August 26, 2021 20:18
Default options of Booking when creating new product
<?php
// Enabling the required option for new product.
function bkap_enable_option_for_new_product( $booking_checked, $duplicate_of, $booking_settings ) {
if ( '' === $booking_settings ) { // enable booking option for new product.
$booking_checked = 'checked';
}
return $booking_checked;
@kartikparmar
kartikparmar / API Call Response
Created July 5, 2021 18:24
API Call Response
Array
(
[headers] => Requests_Utility_CaseInsensitiveDictionary Object
(
[data:protected] => Array
(
[server] => nginx/1.4.6 (Ubuntu)
[date] => Fri, 02 Jul 2021 14:02:51 GMT
[content-type] => text/html; charset=UTF-8
[vary] => Accept-Encoding
<?php
$consumer_key = 'ck_b6dab226d72e3b3da3462f9b51bc672b886f8f85';
$consumer_secret = 'cs_912b18aeedb2883a9c53f877a3c77fc7c0082fc4';
$url = rest_url( 'wp/v2/bkap-bookings/16180/' );
$url = add_query_arg(
array(
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret
),