WordPress at Your Fingertips
function is not described

WC_Shipping_Flat_Rate::fee() public WC 1.0

Work out fee (shortcode).

{} It's a method of the class: WC_Shipping_Flat_Rate{}

No Hooks.

Return

String.

Usage

$WC_Shipping_Flat_Rate = new WC_Shipping_Flat_Rate();
$WC_Shipping_Flat_Rate->fee( $atts );
$atts(array) (required)
Attributes.

Code of WC_Shipping_Flat_Rate::fee() WC 5.9.0

public function fee( $atts ) {
	$atts = shortcode_atts(
		array(
			'percent' => '',
			'min_fee' => '',
			'max_fee' => '',
		),
		$atts,
		'fee'
	);

	$calculated_fee = 0;

	if ( $atts['percent'] ) {
		$calculated_fee = $this->fee_cost * ( floatval( $atts['percent'] ) / 100 );
	}

	if ( $atts['min_fee'] && $calculated_fee < $atts['min_fee'] ) {
		$calculated_fee = $atts['min_fee'];
	}

	if ( $atts['max_fee'] && $calculated_fee > $atts['max_fee'] ) {
		$calculated_fee = $atts['max_fee'];
	}

	return $calculated_fee;
}