Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rajeshsingh520/e401fc146a746b611efff9c6f0eff469 to your computer and use it in GitHub Desktop.
Save rajeshsingh520/e401fc146a746b611efff9c6f0eff469 to your computer and use it in GitHub Desktop.
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;
}
}
if( $if_exists ) return false;
return $json;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment