WC_Gateway_Paypal_Request::get_line_item_args()protectedWC 1.0

Get line item args for paypal request.

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_line_item_args( $order, $force_one_line_item );
$order(WC_Order) (required)
Order object.
$force_one_line_item(true|false)
Create only one item for this order.
Default: false

WC_Gateway_Paypal_Request::get_line_item_args() code WC 8.6.1

protected function get_line_item_args( $order, $force_one_line_item = false ) {
	$line_item_args = array();

	if ( $force_one_line_item ) {
		/**
		 * Send order as a single item.
		 *
		 * For shipping, we longer use shipping_1 because paypal ignores it if *any* shipping rules are within paypal, and paypal ignores anything over 5 digits (999.99 is the max).
		 */
		$line_item_args = $this->get_line_item_args_single_item( $order );
	} else {
		/**
		 * Passing a line item per product if supported.
		 */
		$this->prepare_line_items( $order );
		$line_item_args['tax_cart'] = $this->number_format( $order->get_total_tax(), $order );

		if ( $order->get_total_discount() > 0 ) {
			$line_item_args['discount_amount_cart'] = $this->number_format( $this->round( $order->get_total_discount(), $order ), $order );
		}

		$line_item_args = array_merge( $line_item_args, $this->get_shipping_cost_line_item( $order, false ) );
		$line_item_args = array_merge( $line_item_args, $this->get_line_items() );

	}

	return $line_item_args;
}