Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
@rajeshsingh520
rajeshsingh520 / disable-estiamte-date-for-backorder-product.php
Created June 13, 2020 03:42
Disable estiamte for backorder product
<?php
add_filter('pisol_edd_product_estimate', 'custom_estimate_filter',10,3);
function custom_estimate_filter($estimates, $product, $shipping_method){
foreach($estimates as $product_id => $estimate){
$wc_product = wc_get_product($product_id);
if($wc_product->is_on_backorder()){
$estimates[$product_id] = null;
}
}
@rajeshsingh520
rajeshsingh520 / filter-to-modify-time-slots.php
Last active June 14, 2020 01:47
modify time slots for date or date
<?php
add_filter('pisol_dtt_forced_time_slots', 'filter_time_slots',10, 4);
function filter_time_slots($time_slots, $day_if_week, $date, $delviery_type){
/**
you can make your custom logic to here to add new time slots, or remove existing, based on the day or specific date
$time_slots = array(
array('from' =>"12:00 AM", 'to' => "12:15 AM", 'order_limit' => ""),
@rajeshsingh520
rajeshsingh520 / next-day-time-slot-adjusted-for-preparation-time.php
Created June 15, 2020 09:58
If time for today is less then 15:00 then all time slot will be avialbel for tomorrow, if it goes above 15:00 then only time slot with end time above 12:00 will be avialable for pickup
<?php
class pisol_axd659_next_day_cutoff{
function __construct($cutoff_time, $next_day_time){
$this->cutoff_time = $cutoff_time;
$this->next_day_time = $next_day_time;
add_filter('pisol_dtt_time_slot_filter', array($this, 'next_day_filter'),10, 2);
}
function next_day_filter($times, $date){
<?php
add_filter('pisol_dtt_setting_filter_pi_type', 'allowDeliveryWhenProduct');
function allowDeliveryWhenProduct($type){
$both_for_this_products = array(636, 637); // put the id's of the product for which you want both delivery and pickup to be available
if(isset(WC()->cart)){
foreach( WC()->cart->get_cart() as $cart_item ) {
if(in_array($cart_item['product_id'], $both_for_this_products)){
<?php
/**
if a slot has already reached the max quanity allowed
for the product and user has this product in his cart then the slot will be removed
*/
class pisol_quanity_limit_for_product{
private $product_id = 637; // this is the product for order restriction
private $limit = 2; // this is the slot limit of product quantity,
<?php
/**
when this products will be in the cart then no order limit will be applied,
when the user will have another product along with this products then the order limit will be applied
*/
add_filter("pisol_disable_order_limit_check", 'pisol_disable_order_limit_for_products');
function pisol_disable_order_limit_for_products(){
$disable_limit_for_products = array(636, 637); // disable order limit for this products
<?php
/**
18:00 when the time goes past 18:00 for today user will only see the time slot that are 9:15 or after 9:15
if the time is below 18:00 today user will see all the slot for tomorrow
you need to copy the below code in your theme functions.php file
*/
new pisol_axd659_next_day_cutoff('18:00', '09:15');
class pisol_axd659_next_day_cutoff{
@rajeshsingh520
rajeshsingh520 / force-product-to-be-ordered-individually.php
Last active September 23, 2020 02:16
this code will foce a certain group of product to be ordered individually in this example product 636 and 637 can be orderd togather but they cant be ordered along with some another product
/**
this code will foce a certain group of product to be ordered individually in this example product 636 and 637 can be orderd
togather but they can be ordered along with some another product
*/
add_filter( 'woocommerce_check_cart_items', 'bbloomer_only_one_in_cart');
function bbloomer_only_one_in_cart( ) {
@rajeshsingh520
rajeshsingh520 / dining-tax.php
Last active June 25, 2020 10:46
Add extra dining fees for dining at restaurent
<?php
function woocommerce_dining_fees() {
if(class_exists('pi_dtt_delivery_type')){
$delivery_type = pi_dtt_delivery_type::getType();
if($delivery_type === 'dining'){
$total = WC()->cart->get_subtotal( );
$fee = $total * 10 /100;
WC()->cart->add_fee('Dining tax (10%):', $fee);
}
<?php
/*
$order_id will be the order number whose detail you want to access
*/
$type = get_post_meta( $order_id, 'pi_delivery_type', true ); // delivery type 'delivery' or 'pickup'
$date = get_post_meta( $order_id, 'pi_system_delivery_date', true ); // date in yyyy/mm/dd format
$time = get_post_meta( $order_id, 'pi_delivery_time', true ); // delivery time