WC_Gateway_Paypal_Request::add_line_item( string $item_name, int $quantity = 1, float $amount = 0.0, string $item_number = '' )

Add PayPal Line Item.


Description Description


Parameters Parameters

$item_name

(Required) Item name.

$quantity

(Optional) Item quantity.

Default value: 1

$amount

(Optional) Amount.

Default value: 0.0

$item_number

(Optional) Item number.

Default value: ''


Top ↑

Source Source

File: includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php

	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 );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.