Automattic\WooCommerce\Internal\Admin\WCPayPromotion

Init::get_wc_pay_promotion_spec()public staticWC 1.0

Get WooPayments promotion spec.

Method of the class: Init{}

No Hooks.

Return

Object|false. WooPayments promotion spec or false if there isn't one.

Usage

$result = Init::get_wc_pay_promotion_spec( $fetch_from_remote );
$fetch_from_remote(true|false)
Whether to fetch the spec from remote or not.
Default: true

Init::get_wc_pay_promotion_spec() code WC 9.7.1

public static function get_wc_pay_promotion_spec( $fetch_from_remote = true ) {
	$promotions            = $fetch_from_remote ? self::get_promotions() : self::get_cached_or_default_promotions();
	$wc_pay_promotion_spec = array_values(
		array_filter(
			$promotions,
			function ( $promotion ) {
				return isset( $promotion->plugins ) && in_array( 'woocommerce-payments', $promotion->plugins, true );
			}
		)
	);

	return current( $wc_pay_promotion_spec );
}