Automattic\WooCommerce\Internal\Admin\Settings

PaymentsController::add_allowed_promo_notespublicWC 1.0

Adds promo note IDs to the list of allowed ones.

Method of the class: PaymentsController{}

No Hooks.

Returns

Array. The updated list of allowed promo note IDs.

Usage

$PaymentsController = new PaymentsController();
$PaymentsController->add_allowed_promo_notes( $promo_notes ): array;
$promo_notes(array)
Allowed promo note IDs.
Default: array()

PaymentsController::add_allowed_promo_notes() code WC 9.9.4

public function add_allowed_promo_notes( array $promo_notes = array() ): array {
	try {
		$providers = $this->payments->get_payment_providers( $this->payments->get_country() );
	} 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',
				'error'  => $e,
			)
		);

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