How filter the rate calculation
Note: Please copy and paste this code in functions.php of your current theme.
function custom_wpcsr_shipment_cost_callback( $cost, $rate_id, $package_weight, $protection, $shipment_id ){ $rateInfo = get_wpcsr_rate_by_id( $rate_id ); $new_total_cost = 0; // Check if it is Cost per Weight if( $rateInfo->rate_type ){ // Check if the Weight Cost is not 0 if( $rateInfo->weight_cost && (float)$rateInfo->weight_cost > 0 ){ $new_total_cost += ( ( $package_weight - (float)$rateInfo->min_weight ) * (float)$rateInfo->weight_cost ); } } // Else it is Flat Rate else{ $new_total_cost = $rateInfo->price; } // Add the Protection/Insurance to the New Total Cost if( (int)$protection == 1 ){ $new_total_cost += (float)$rateInfo->rate_protection; } return $new_total_cost; } add_filter('wpcsr_shipment_cost', 'custom_wpcsr_shipment_cost_callback', 10, 5 );