WC_Shipping_Legacy_Local_Delivery::calculate_shipping()
Calculate_shipping function.
Метод класса: WC_Shipping_Legacy_Local_Delivery{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WC_Shipping_Legacy_Local_Delivery = new WC_Shipping_Legacy_Local_Delivery(); $WC_Shipping_Legacy_Local_Delivery->calculate_shipping( $package );
- $package(массив)
- -
По умолчанию: array())
Код WC_Shipping_Legacy_Local_Delivery::calculate_shipping() WC Shipping Legacy Local Delivery::calculate shipping WC 9.2.3
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 ); }