*/ public static function allowedShowOnIds(bool $isAbo, string $shippingIsFor): array { if ($shippingIsFor === 'me' || $shippingIsFor === 'abo-me') { return $isAbo ? ['12', '13'] : ['2']; } return $isAbo ? ['12', '13'] : ['3']; } /** * @param list $allowedIds */ public static function productMatchesShowOn(Product $product, array $allowedIds): bool { $showOn = $product->show_on; if (! is_array($showOn)) { return false; } foreach ($allowedIds as $id) { foreach ($showOn as $value) { if ((string) $value === (string) $id) { return true; } } } return false; } public static function isProductAllowedInContext(Product $product, bool $isAbo, string $shippingIsFor): bool { return self::productMatchesShowOn($product, self::allowedShowOnIds($isAbo, $shippingIsFor)); } public static function isProductAllowedInCustomerWebshop(Product $product): bool { return self::isProductAllowedInContext($product, false, 'ot-customer'); } }