$offers The automatic discounts running now. * @return list */ public static function for(Store $store, Collection $offers): array { if (! $store->announcement_enabled) { return []; } return array_merge(self::own($store), self::automatic($store, $offers)); } /** * Lines the store writes by itself. * * @param Collection $offers * @return list */ public static function automatic(Store $store, Collection $offers): array { $language = $store->language->value; $lines = []; if ($store->free_shipping_over !== null) { $lines[] = $store->free_shipping_over === 0 ? StorefrontText::line($language, 'announce_free_shipping_all') : StorefrontText::line($language, 'announce_free_shipping', [':amount' => 'RM '.number_format($store->free_shipping_over / 100, 2)]); } foreach ($offers->take(3) as $offer) { $lines[] = $offer->name.': '.$offer->describe($language); } return $lines; } /** * @return list */ private static function own(Store $store): array { return array_slice(array_values(array_filter( array_map(fn (mixed $line) => trim((string) $line), $store->announcement_messages ?? []), fn (string $line) => $line !== '', )), 0, self::MAX_OWN); } }