Skip to content

Instantly share code, notes, and snippets.

View kartikparmar's full-sized avatar

Kartik Parmar kartikparmar

  • Mumbai
View GitHub Profile
@kartikparmar
kartikparmar / product
Created December 19, 2022 12:43
product
{
"id": 4586,
"name": "Date and time",
"slug": "date-and-time-4",
"permalink": "https://team-sandbox.tychesoftwares.com/kartik/product/date-and-time-4/",
"date_created": "2022-12-19T16:29:06",
"date_created_gmt": "2022-12-19T10:59:06",
"date_modified": "2022-12-19T16:29:07",
"date_modified_gmt": "2022-12-19T10:59:07",
"type": "simple",
@kartikparmar
kartikparmar / functions.php
Last active December 10, 2022 05:08
Dave Changes - Ticket 46398
<?php
function custom_change_cart_meta( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
return;
@kartikparmar
kartikparmar / functions.php
Created December 1, 2022 06:08
Setting booking fields data from the URL parameters.
<?php
/**
* Setting booking fields data from the URL parameters. start and end date is passed in the URL parameters. This can be changed according to business requirements. e.g check_in and check_out.
*/
function bkap_set_bookings_via_get() {
if ( isset( $_GET['start'] ) && isset( $_GET['end'] ) ) {
$start_date = $_GET['start'];
@kartikparmar
kartikparmar / functions.php
Last active December 4, 2022 09:52
When manually creating booking, set order status to pending payment and booking status to pending-confirmation
<?php
function bkap_booking_status_on_create_order( $status ) {
if ( is_admin() ) {
if ( isset( $_POST['original_post_status'] ) ) {
return $status;
}
$status = 'pending-confirmation';
}
@kartikparmar
kartikparmar / functions.php
Created November 2, 2022 17:19
Global Time Slots Booking for the Durations Based Time
<?php
/**
* Global Time Slots Booking for the Durations Based Time.
*/
function bkap_additional_bookings_to_be_considered( $booking_idss, $product_id, $resource_id ) {
// Getting Product ids that has Duration Based Time Booking Type.
$args = array(
'post_type' => 'product',
array(
'post_type' => 'bkap_booking',
'post_status' => array( 'paid', 'pending-confirmation', 'confirmed' ),
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_bkap_start',
'value' => date( 'YmdHis', strtotime( 'today' ) ),
@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 );