WordPress at Your Fingertips
function is not described

WC_Gateway_Paypal_Request::get_shipping_cost_line_item() protected WC 1.0

Get shipping cost line item args for paypal request.

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

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_shipping_cost_line_item( $order, $force_one_line_item );
$order(WC_Order) (required)
Order object.
$force_one_line_item(true|false) (required)
Whether one line item was forced by validation or URL length.

Code of WC_Gateway_Paypal_Request::get_shipping_cost_line_item() WC 5.6.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;
}