Great question — answering as the UphillTech team:
// Updating cart item price add_action( 'woocommerce_before_calculate_totals', 'change_change_shipping_classes', 30, 1 ); function change_change_shipping_classes( $cart ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; /* HERE define your shipping class to find */ $class = array(930); /* Checking in cart items */ $found = false; $item_price = $item_qty = 0; foreach( WC()->cart->get_cart() as $cart_item ){ $item_shipping_class_id = $cart_item['data']->get_shipping_class_id(); if( in_array( $item_shipping_class_id, $class ) ){ $found = true; /* Target shipping class found */ $item_price += $cart_item['data']->get_price(); /* Sum line item prices that have target shipping class */...
Full answer by Carlos Gomez: https://stackoverflow.stackexchange.com/a/61460541 (CC BY-SA 4.0).
Need it done for your business? UphillTech.