Automattic\WooCommerce\Gateways\PayPal

Request::generate_paypal_invoice_id_with_unique_suffix │ private │ WC 1.0

Generate a unique invoice ID for the order.

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

Хуков нет.

Возвращает

string.

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

// private - только в коде основоного (родительского) класса
$result = $this->generate_paypal_invoice_id_with_unique_suffix( $order ): string;
$order(WC_Order) (обязательный)
Order object.

Код Request::generate_paypal_invoice_id_with_unique_suffix() WC 11.2.2

private function generate_paypal_invoice_id_with_unique_suffix( WC_Order $order ): string {
	$prefix          = $this->gateway->get_option( 'invoice_prefix' );
	$order_number    = $order->get_order_number();
	$base_invoice_id = $prefix . $order_number;

	// Generate a unique ID for the invoice.
	$unique_id = bin2hex( random_bytes( 6 ) );

	$invoice_id = $this->limit_length( $base_invoice_id . '-' . $unique_id, PayPalConstants::PAYPAL_INVOICE_ID_MAX_LENGTH );
	return $invoice_id;
}