Automattic\WooCommerce\Internal\Admin\Settings

PaymentsController::add_allowed_promo_notespublicWC 1.0

Adds promo note IDs to the list of allowed ones.

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

Хуков нет.

Возвращает

Массив. The updated list of allowed promo note IDs.

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

$PaymentsController = new PaymentsController();
$PaymentsController->add_allowed_promo_notes( $promo_notes ): array;
$promo_notes(массив)
Allowed promo note IDs.
По умолчанию: array()

Код PaymentsController::add_allowed_promo_notes() WC 10.4.3

public function add_allowed_promo_notes( $promo_notes = array() ): array {
	// Reset the value if the type is invalid.
	if ( ! is_array( $promo_notes ) ) {
		$promo_notes = array();
	}

	try {
		$providers = $this->payments->get_payment_providers( $this->payments->get_country(), false );
	} catch ( Throwable $e ) {
		// Catch everything since we don't want to break all the WP admin pages.
		// Log so we can investigate.
		SafeGlobalFunctionProxy::wc_get_logger()->error(
			'Failed to get payment providers: ' . $e->getMessage(),
			array(
				'source' => 'settings-payments',
			)
		);

		return $promo_notes;
	}

	// Add all incentive promo IDs to the allowed promo notes list.
	foreach ( $providers as $provider ) {
		if ( ! empty( $provider['_incentive']['promo_id'] ) ) {
			$promo_notes[] = $provider['_incentive']['promo_id'];
		}
	}

	return $promo_notes;
}