WC_Admin_Marketplace_Promotions::get_orders_promo_card
Get the first active promo card that targets the Orders screen, together with the store's order count for instrumentation. Returns null when none is eligible.
Resolved once per request (the enqueue and render hooks both need it).
Method of the class: WC_Admin_Marketplace_Promotions{}
No Hooks.
Returns
Array|null.
Usage
$result = WC_Admin_Marketplace_Promotions::get_orders_promo_card();
WC_Admin_Marketplace_Promotions::get_orders_promo_card() WC Admin Marketplace Promotions::get orders promo card code WC 11.0.0
public static function get_orders_promo_card() {
if ( self::$orders_promo_card_resolved ) {
return self::$orders_promo_card;
}
self::$orders_promo_card_resolved = true;
$dismissed = self::get_dismissed_promo_ids();
foreach ( self::get_active_promotions() as $promotion ) {
if ( ! is_array( $promotion ) || 'promo-card' !== ( $promotion['format'] ?? '' ) ) {
continue;
}
if ( ! self::promotion_targets_orders( $promotion ) ) {
continue;
}
// An id is required so the card can be dismissed permanently; skip ones already dismissed.
$id = isset( $promotion['id'] ) ? (string) $promotion['id'] : '';
if ( '' === $id || in_array( $id, $dismissed, true ) ) {
continue;
}
self::$orders_promo_card = array(
'id' => $id,
'promotion' => $promotion,
'order_count' => ( new OrdersProvider() )->get_order_count(),
);
break;
}
return self::$orders_promo_card;
}