WC_Shipping_Method::get_rate_id()publicWC 2.6.0

Returns a rate ID based on this methods ID and instance, with an optional suffix if distinguishing between multiple rates.

Method of the class: WC_Shipping_Method{}

No Hooks.

Return

String.

Usage

$WC_Shipping_Method = new WC_Shipping_Method();
$WC_Shipping_Method->get_rate_id( $suffix );
$suffix(string)
Suffix.
Default: ''

Changelog

Since 2.6.0 Introduced.

WC_Shipping_Method::get_rate_id() code WC 8.7.0

public function get_rate_id( $suffix = '' ) {
	$rate_id = array( $this->id );

	if ( $this->instance_id ) {
		$rate_id[] = $this->instance_id;
	}

	if ( $suffix ) {
		$rate_id[] = $suffix;
	}

	return implode( ':', $rate_id );
}