Skip to content

Instantly share code, notes, and snippets.

View kartikparmar's full-sized avatar

Kartik Parmar kartikparmar

  • Mumbai
View GitHub Profile
<?php
function bkap_show_hide_persons_based_on_date( $data ) {
$persons_to_hide = array(
'84217' => array( // 84217 is product id
array(
'dates' => '2023-06-25,2023-06-22', // in Y-m-d format.
'person_ids' => array( 84226, 84227 ), // 84226, 84227 are persons ids to hide
),
array(
@kartikparmar
kartikparmar / Wp-vue.php
Last active May 5, 2023 14:37
This file is to create wp plugin using vue
<?php
/**
* Plugin Name: Vue Settings Page Plugin
* Description: A WordPress plugin that adds a settings page with two tabs using Vue.js.
* Version: 1.0.0
@kartikparmar
kartikparmar / functions.php
Created March 28, 2023 17:53
Changing the product price in the renewal order.
<?php
add_filter( 'wcs_renewal_order_created', 'test_change_renewal_order_price', 10, 2 );
function test_change_renewal_order_price( $renewal_order, $subscription ) {
// Get the line item for the subscription product
$line_items = $renewal_order->get_items();
foreach( $line_items as $line_item ) {
@kartikparmar
kartikparmar / response
Created December 20, 2022 10:15
response for time availability information
[
[
{
"date": "2022-12-27",
"start_time": "10:00",
"end_time": "12:00",
"availability": 10
}
{
"date": "2022-12-27",
@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' ) ),