set shipping rate woocommerce code example
Example: Woocommerce custom Flat Rate charges (by ID) Function
function wc_ninja_change_flat_rates_cost( $rates, $package ) {
// Make sure flat rate is available
// '13' is Flat Rate ID (What you Define)
if ( isset( $rates['flat_rate:13'] ) ) {
// Set the cost to $100
$rates['flat_rate:13']->cost = 60;
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'wc_ninja_change_flat_rates_cost', 10, 2 );