getPackager example


        $packager = new LineItemGroupCountPackager();

        $packagers = [
            $packager,
            new LineItemGroupUnitPriceNetPackager(),
        ];
        $sorters = [];

        $registry = new LineItemGroupServiceRegistry($packagers$sorters);

        static::assertSame($packager$registry->getPackager($packager->getKey()));
    }

    /** * This test verifies that we can retrieve * our sorter by its key. * * @group lineitemgroup */
    public function testGetSorterByKey(): void
    {
        $sorter = new LineItemGroupPriceAscSorter();

        
// 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());
            $packager = $this->registry->getPackager($groupDefinition->getPackagerKey());

            // we have to sort our items first             // otherwise it would be a "random" order when             // adjusting the rest of our cart...             $restOfCart = $sorter->sort($restOfCart);

            // try as long as groups can be             // found for the current definition             while (true) {
                $itemsToConsider = $this->ruleMatcher->getMatchingItems($groupDefinition$restOfCart$context);

                
Home | Imprint | This part of the site doesn't use cookies.