WC_Shipping_Legacy_Flat_Rate::calc_percentage_adjustment
Deprecated since 2.4.0. It is no longer supported and may be removed in future releases. It is recommended to replace this function with the same one.
Calculate the percentage adjustment for each shipping rate.
Method of the class: WC_Shipping_Legacy_Flat_Rate{}
No Hooks.
Returns
float.
Usage
$WC_Shipping_Legacy_Flat_Rate = new WC_Shipping_Legacy_Flat_Rate(); $WC_Shipping_Legacy_Flat_Rate->calc_percentage_adjustment( $cost, $percent_adjustment, $percent_operator, $base_price );
- $cost(float) (required)
- Cost.
- $percent_adjustment(float) (required)
- Percent adjustment.
- $percent_operator(string) (required)
- Percent operator.
- $base_price(float) (required)
- Base price.
Changelog
| Deprecated since | 2.4.0 |
WC_Shipping_Legacy_Flat_Rate::calc_percentage_adjustment() WC Shipping Legacy Flat Rate::calc percentage adjustment code WC 10.7.0
public function calc_percentage_adjustment( $cost, $percent_adjustment, $percent_operator, $base_price ) {
if ( '+' === $percent_operator ) {
$cost += $percent_adjustment * $base_price;
} else {
$cost -= $percent_adjustment * $base_price;
}
return $cost;
}