use Shopware\Core\Checkout\Cart\CartValidatorInterface;
use Shopware\Core\Checkout\Cart\Error\ErrorCollection;
use Shopware\Core\Checkout\Cart\LineItem\LineItem;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
#[Package('checkout')]
class ProductLineItemValidator implements CartValidatorInterface
{ public function validate(Cart
$cart, ErrorCollection
$errors, SalesChannelContext
$context): void
{ $behavior =
$cart->
getBehavior();
if ($behavior !== null &&
$behavior->
hasPermission(ProductCartProcessor::SKIP_PRODUCT_STOCK_VALIDATION
)) { return;
} $productLineItems =
array_filter($cart->
getLineItems()->
getFlat(),
static fn (LineItem
$lineItem) =>
$lineItem->
getType() === LineItem::PRODUCT_LINE_ITEM_TYPE
);
$quantities =
[];
$refs =
[];
foreach ($productLineItems as $lineItem) { $productId =
$lineItem->
getReferencedId();
if ($productId === null
) {