Skip to main content

fc_shipping_method_option_price

Type: Filter

Filters the shipping method option price.

Signature​

apply_filters( 'fc_shipping_method_option_price', $method_costs, $method );

Parameters​

NameTypeDescription
$method_costsmixedMethod costs.
$method\WC_Shipping_RateMethod.

Since​

  • 3.0.2

Source: inc/checkout-steps.php

Examples​

add_filter( 'fc_shipping_method_option_price',
/**
* Customize shipping method price display.
*
* @param mixed $method_costs Method costs.
* @param \WC_Shipping_Rate $method Method.
* @return mixed Filtered value.
*/
function( $method_costs, $method ) {
$cost = $method->get_cost();
if ( $cost == 0 ) {
return '<span class="free-shipping-text">' . __( 'FREE', 'my-theme' ) . '</span>';
}
return $method_costs;
},
10,
2
);

add_filter( 'fc_shipping_method_has_cost',
/**
* Always show cost for all shipping methods.
*
* @param mixed $value Value to filter.
* @param \WC_Shipping_Rate $method Method.
* @return mixed Filtered value.
*/
function( $value, $method ) {
return true;
},
10,
2
);