WC_Gateway_Paypal_Request::fix_request_length()protectedWC 1.0

If the default request with line items is too long, generate a new one with only one line item.

If URL is longer than 2,083 chars, ignore line items and send cart to Paypal as a single item. One item's name can only be 127 characters long, so the URL should not be longer than limit. URL character limit via: https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.

Метод класса: WC_Gateway_Paypal_Request{}

Хуки из метода

Возвращает

Массив.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->fix_request_length( $order, $paypal_args );
$order(WC_Order) (обязательный)
Order to be sent to Paypal.
$paypal_args(массив) (обязательный)
Arguments sent to Paypal in the request.

Код WC_Gateway_Paypal_Request::fix_request_length() WC 8.7.0

protected function fix_request_length( $order, $paypal_args ) {
	$max_paypal_length = 2083;
	$query_candidate   = http_build_query( $paypal_args, '', '&' );

	if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
		return $paypal_args;
	}

	return apply_filters(
		'woocommerce_paypal_args',
		array_merge(
			$this->get_transaction_args( $order ),
			$this->get_line_item_args( $order, true )
		),
		$order
	);

}