Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
@rajeshsingh520
rajeshsingh520 / disable-date-time-plugin-for-category-of-product.php
Last active February 4, 2021 11:55
Disable date time plugin for category of product
class pisol_marp_disable_dtt_plugin_options_for_category{
function __construct(){
add_filter('pisol_disable_dtt_completely', array($this, 'disableDateTimePlugin'));
}
function disableDateTimePlugin($value){
if(is_admin()) return;
$disabe_for_cat = array(107, 109); // Category id for which the plugin will be disabled
@rajeshsingh520
rajeshsingh520 / enable-date-time-plugin-for-category-of-product.php
Last active May 17, 2020 10:22
Enable date time plugin for specific category of product only
<?php
add_action( 'wp_loaded', 'pisol_enable_plugin_for_category' );
function pisol_enable_plugin_for_category(){
$enable_for_cat = 107; // this will be your category id for which you want to enable the plugin
$plugin_disabled = true;
if(isset(WC()->cart)){
foreach( WC()->cart->get_cart() as $cart_item ) {
@rajeshsingh520
rajeshsingh520 / different-date-placeholder.php
Last active May 18, 2020 11:10
set different date place holder for date and time plugin
<?php
add_action('wp_enqueue_scripts','pisol_placeholder_replacement');
function pisol_placeholder_replacement(){
$js = 'jQuery(function($){
window.pi_date_options.datePlaceholder = "Date.....";
});';
wp_add_inline_script('jquery',$js,'after');
}
@rajeshsingh520
rajeshsingh520 / restrict-delivery-for-perticular-product.php
Created May 18, 2020 10:42
Restrict delivery for certain product only
<?php
add_filter('pisol_dtt_setting_filter_pi_type', 'allowDeliveryWhenProduct');
function allowDeliveryWhenProduct($type){
$delivery_only_for_this_product = 636;
$type = 'Pickup';
if(isset(WC()->cart)){
foreach( WC()->cart->get_cart() as $cart_item ) {
@rajeshsingh520
rajeshsingh520 / force-pickup-for-products.php
Last active June 21, 2020 09:29
Force pickup option for the products
<?php
add_filter('pisol_dtt_setting_filter_pi_type', 'forcePickupforProduct');
function forcePickupforProduct($type){
$only_pickup_for_this_products = array(636, 637); // put the id's of the product for which you only want pickup
if(isset(WC()->cart)){
foreach( WC()->cart->get_cart() as $cart_item ) {
if(in_array($cart_item['product_id'],$only_pickup_for_this_products)){
@rajeshsingh520
rajeshsingh520 / pickup-now-delivery-now-option.php
Last active May 21, 2020 07:02
Show pickup now or delivery now option in the time select box
<?php
add_filter('pisol_dtt_time_slot_filter','pickupNow',10, 2);
add_filter('pisol_dtt_time_range_filter','pickupNow',10, 2);
function pickupNow($time, $date){
$type = pi_dtt_delivery_type::getType();
$current_date = current_time('Y/m/d');
if($type == 'pickup' && $current_date == $date){
@rajeshsingh520
rajeshsingh520 / disable-date-time-popup-onspecific-page.php
Created May 22, 2020 09:12
Disable preference popup plugin on specific page
<?php
add_filter('pisol_dppp_enable_popup', function($value){
if(is_page(334)){ // this will disable the preference popup on page 334
return false;
}
return $value;
});
<?php
class pisol_marp_disable_dtt_plugin_options{
function __construct(){
add_filter('pisol_disable_dtt_completely', array($this, 'disableDateTimePlugin'));
}
function disableDateTimePlugin($value){
if(is_admin()) return;
@rajeshsingh520
rajeshsingh520 / product-quanity-based-order-limit.php
Last active August 13, 2020 10:04
If there is 50 unit sell limit of product A, quanity based order limit for time slot
<?php
class pisol_quanity_limit_for_product{
private $product_id = 637; // this is the product for which your want to limit the slot
private $limit = 10; // this is the slot limit of product quantity
function __construct(){
add_filter('pisol_dtt_time_slot_filter', array($this,'timeFilter'),100, 2);
}
@rajeshsingh520
rajeshsingh520 / hide-free-shipping-bar-if-shipping-class-in-cart.php
Created May 27, 2020 05:17
hide free shipping bar if certail shipping class product is present in the cart
<?php
add_filter('pisol_fsnw_final_ajax_filter', 'disableFreeShippingBarForClassOfProduct');
function disableFreeShippingBarForClassOfProduct($json){
$shipping_classes = array(128); // shipping class id for which the free shipping bar will be hidden
$if_exists = false;
foreach( WC()->cart->cart_contents as $key => $values ){
if( in_array( $values[ 'data' ]->get_shipping_class_id(), $shipping_classes ) ){
$if_exists = true;