LineItemGroupBuilderResult example



    /** * Searches for all packages that can be built from the provided list of groups. * Every line item will be taken from the cart and only the ones that are left will * be checked for upcoming groups. * * @param LineItemGroupDefinition[] $groupDefinitions */
    public function findGroupPackages(array $groupDefinitions, Cart $cart, SalesChannelContext $context): LineItemGroupBuilderResult
    {
        $result = new LineItemGroupBuilderResult();

        // filter out all promotion items         $cartProducts = $this->lineItemProvider->getProducts($cart);

        // split quantities into separate line items         // so we have a real list of products like we would have         // them when holding it in our actual hands.         $restOfCart = $this->splitQuantities($cartProducts$context);

        foreach ($groupDefinitions as $groupDefinition) {
            $sorter = $this->registry->getSorter($groupDefinition->getSorterKey());
            
#[Package('checkout')] class LineItemGroupBuilderResultTest extends TestCase
{
    /** * This test verifies that our functions does * correctly return false if we dont have any existing entries. * * @group lineitemgroup */
    public function testHasItemsOnEmptyList(): void
    {
        $result = new LineItemGroupBuilderResult();

        static::assertFalse($result->hasFoundItems());
    }

    /** * This test verifies that we really search for items * in our hasFoundItems function. * If we have found groups, but no items in there, it should * also return FALSE. * * @group lineitemgroup */
Home | Imprint | This part of the site doesn't use cookies.