for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Shopware\Core\Checkout\Cart\Facade;
use Shopware\Core\Checkout\Cart\Cart;
use Shopware\Core\Checkout\Cart\CartBehavior;
use Shopware\Core\Checkout\Cart\LineItem\LineItem;
use Shopware\Core\Checkout\Cart\LineItemFactoryRegistry;
use Shopware\Core\Checkout\Cart\Processor;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
/**
* @internal
*/
#[Package('checkout')]
class CartFacadeHelper
{
public function __construct(
private readonly LineItemFactoryRegistry $factory,
private readonly Processor $processor
) {
}
public function product(string $productId, int $quantity, SalesChannelContext $context): LineItem
$data = [
'type' => LineItem::PRODUCT_LINE_ITEM_TYPE,
'id' => $productId,
'referencedId' => $productId,
'quantity' => $quantity,
];
return $this->factory->create($data, $context);
public function calculate(Cart $cart, CartBehavior $behavior, SalesChannelContext $context): Cart
return $this->processor->process($cart, $context, $behavior);