Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rajeshsingh520/747298aaebbdec74a8f65b3e80993147 to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/747298aaebbdec74a8f65b3e80993147 to your computer and use it in GitHub Desktop.
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 ) {
if($delivery_only_for_this_product == $cart_item['product_id']){
$type = "Both";
}
}
}
return $type;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment