WC_Gateway_Paypal_Request::get_line_item_args( WC_Order $order, bool $force_one_line_item = false )
Get line item args for paypal request.
Description Description
Parameters Parameters
- $order
-
(Required) Order object.
- $force_one_line_item
-
(Optional) Create only one item for this order.
Default value: false
Return Return
(array)
Source Source
File: includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
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;
}