WordPress at Your Fingertips
function is not described

WC_Gateway_Paypal_Request::add_line_item() protected WC 1.0

Add PayPal Line Item.

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

Hooks from the method
Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->add_line_item( $item_name, $quantity, $amount, $item_number );
$item_name(string) (required)
Item name.
$quantity(int)
Item quantity.
Default: 1
$amount(float)
Amount.
Default: 0.0
$item_number(string)
Item number.
Default: ''

Code of WC_Gateway_Paypal_Request::add_line_item() WC 5.6.0

protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
	$index = ( count( $this->line_items ) / 4 ) + 1;

	$item = apply_filters(
		'woocommerce_paypal_line_item',
		array(
			'item_name'   => html_entity_decode( wc_trim_string( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'woocommerce' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
			'quantity'    => (int) $quantity,
			'amount'      => wc_float_to_string( (float) $amount ),
			'item_number' => $item_number,
		),
		$item_name,
		$quantity,
		$amount,
		$item_number
	);

	$this->line_items[ 'item_name_' . $index ]   = $this->limit_length( $item['item_name'], 127 );
	$this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
	$this->line_items[ 'amount_' . $index ]      = $item['amount'];
	$this->line_items[ 'item_number_' . $index ] = $this->limit_length( $item['item_number'], 127 );
}