WordPress at Your Fingertips
function is not described

WC_Shipping_Legacy_Local_Delivery::calculate_shipping() public WC 1.0

Calculate_shipping function.

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

No Hooks.

Return

null. Nothing.

Usage

$WC_Shipping_Legacy_Local_Delivery = new WC_Shipping_Legacy_Local_Delivery();
$WC_Shipping_Legacy_Local_Delivery->calculate_shipping( $package );
$package(array)
(default: array()).
Default: array()

Code of WC_Shipping_Legacy_Local_Delivery::calculate_shipping() WC 5.9.0

public function calculate_shipping( $package = array() ) {
	$shipping_total = 0;

	switch ( $this->type ) {
		case 'fixed':
			$shipping_total = $this->fee;
			break;
		case 'percent':
			$shipping_total = $package['contents_cost'] * ( $this->fee / 100 );
			break;
		case 'product':
			foreach ( $package['contents'] as $item_id => $values ) {
				if ( $values['quantity'] > 0 && $values['data']->needs_shipping() ) {
					$shipping_total += $this->fee * $values['quantity'];
				}
			}
			break;
	}

	$rate = array(
		'id'      => $this->id,
		'label'   => $this->title,
		'cost'    => $shipping_total,
		'package' => $package,
	);

	$this->add_rate( $rate );
}