Skip to content

Instantly share code, notes, and snippets.



Last active Mar 11, 2020
What would you like to do?
Snippet to skip particular product from shipping rate calculation, if the cart contains multiple shipping classes of given array. Supports PluginHive Shipping Plugins: and ELEX Shipping Plugins
function skip_my_products($skip = false, $product, $package){
$shipping_class_goup = array('class-a','class-b'); // if these shipping classes coming together in the cart
$shipping_class_skip = 'class-a'; // If multiple shipping class of above in the cart, skip this product.
$shipping_class = array();
foreach ($package as $key => $item) {
$shipping_class[] = $item['data']->get_shipping_class();
if( $product['data']->get_shipping_class()==$shipping_class_skip && ( count( array_intersect( $shipping_class, $shipping_class_goup ) > 1 ) ) ){
return true;
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment