private function getCodesFromPlaceholdersIds(Cart $cart, array $lineItemIDs): array
    {
        $codes = [];

        /** @var array $promotionLineItems */
        $promotionLineItems = $this->getPromotionLineItems($cart);

        /** @var LineItem $lineItem */
        foreach ($promotionLineItems as $lineItem) {
            // if our line item is in our list of Ids and
            // if it is a placeholder item, then collect that code.
            if (!in_array($lineItem->getKey(), $lineItemIDs, true)) {
                continue;
            }

            // grab our code from the payload
            // just verify if it really exists to avoid exceptions
            if (array_key_exists('code', $lineItem->getPayload())) {
                $codes[] = $lineItem->getPayload()['code'];
            }
        }

        return $codes;
    }
private function getCodesFromPlaceholdersIds(Cart $cart, array $lineItemIDs): array
    {
        $codes = [];

        /** @var array $promotionLineItems */
        $promotionLineItems = $this->getPromotionLineItems($cart);

        /** @var LineItem $lineItem */
        foreach ($promotionLineItems as $lineItem) {
            // if our line item is in our list of Ids and
            // if it is a placeholder item, then collect that code.
            if (!in_array($lineItem->getKey(), $lineItemIDs, true)) {
                continue;
            }

            // grab our code from the payload
            // just verify if it really exists to avoid exceptions
            if (array_key_exists('code', $lineItem->getPayload())) {
                $codes[] = $lineItem->getPayload()['code'];
            }
        }

        return $codes;
    }
private function getCodesFromPlaceholdersIds ( Cart $ cart , array $ lineItemIDs ) : array { $ codes = [ ] ; /** @var array $promotionLineItems */ $ promotionLineItems = $ this -> getPromotionLineItems ( $ cart ) ; /** @var LineItem $lineItem */ foreach ( $ promotionLineItems as $ lineItem ) { // if our line item is in our list of Ids and // if it is a placeholder item, then collect that code. if ( ! in_array ( $ lineItem -> getKey ( ) , $ lineItemIDs , true ) ) { continue ; } // grab our code from the payload // just verify if it really exists to avoid exceptions if ( array_key_exists ( 'code' , $ lineItem -> getPayload ( ) ) ) { $ codes [ ] = $ lineItem -> getPayload ( ) [ 'code' ] ; } } return $ codes ; }
This function extracts all code strings from the
placeholder items of the provided Ids within the cart.
This function extracts all code strings from the placeholder items of the provided Ids within the cart .