WC_Gateway_Paypal_Request::get_shipping_cost_line_item()protectedWC 1.0

Get shipping cost line item args for paypal request.

Метод класса: WC_Gateway_Paypal_Request{}

Хуков нет.

Возвращает

Массив.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_shipping_cost_line_item( $order, $force_one_line_item );
$order(WC_Order) (обязательный)
Order object.
$force_one_line_item(true|false) (обязательный)
Whether one line item was forced by validation or URL length.

Код WC_Gateway_Paypal_Request::get_shipping_cost_line_item() WC 8.7.0

protected function get_shipping_cost_line_item( $order, $force_one_line_item ) {
	$line_item_args = array();
	$shipping_total = $order->get_shipping_total();
	if ( $force_one_line_item ) {
		$shipping_total += $order->get_shipping_tax();
	}

	// Add shipping costs. Paypal ignores anything over 5 digits (999.99 is the max).
	// We also check that shipping is not the **only** cost as PayPal won't allow payment
	// if the items have no cost.
	if ( $order->get_shipping_total() > 0 && $order->get_shipping_total() < 999.99 && $this->number_format( $order->get_shipping_total() + $order->get_shipping_tax(), $order ) !== $this->number_format( $order->get_total(), $order ) ) {
		$line_item_args['shipping_1'] = $this->number_format( $shipping_total, $order );
	} elseif ( $order->get_shipping_total() > 0 ) {
		/* translators: %s: Order shipping method */
		$this->add_line_item( sprintf( __( 'Shipping via %s', 'woocommerce' ), $order->get_shipping_method() ), 1, $this->number_format( $shipping_total, $order ) );
	}

	return $line_item_args;
}