WC_Shipping_Flat_Rate::fee()publicWC 1.0

Work out fee (shortcode).

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.

WC_Shipping_Flat_Rate::fee() code WC 8.7.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;
}