WC_Gateway_Paypal_Request::fix_request_length( WC_Order $order, array $paypal_args )
If the default request with line items is too long, generate a new one with only one line item.
Description Description
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.
Parameters Parameters
- $order
-
(Required) Order to be sent to Paypal.
- $paypal_args
-
(Required) Arguments sent to Paypal in the request.
Return Return
(array)
Source Source
File: includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
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 ); }