WC_Admin_Marketplace_Promotions::get_promotions_of_format
From the array of promotions, select those of a given format.
Method of the class: WC_Admin_Marketplace_Promotions{}
No Hooks.
Returns
Array.
Usage
$result = WC_Admin_Marketplace_Promotions::get_promotions_of_format( $promotions, $format ): array;
- $promotions(?array)
- Array of data about promotions of all formats.
Default:array() - $format(?string)
- Format we want to filter for.
Default:''
WC_Admin_Marketplace_Promotions::get_promotions_of_format() WC Admin Marketplace Promotions::get promotions of format code WC 10.5.0
private static function get_promotions_of_format( $promotions = array(), $format = '' ): array {
if ( empty( $promotions ) || empty( $format ) ) {
return array();
}
return array_filter(
$promotions,
function( $promotion ) use ( $format ) {
return isset( $promotion['format'] ) && $format === $promotion['format'];
}
);
}