0

I've been trying the following code to add a break line when a product title has more than 60 characters:

    if ($item->getProductType() == 'bundle') {
        foreach ($item->getChildren() as $child) {
            $childProduct = $this->productRepositoryInterface->getById(
                $child->getProductId(),
                false,
                $quote->getStoreId()
            );
            $childName = $childProduct->getName();
            $bundleText[] = $childName;
        }
        $line[] = [
            'text' => wordwrap($childName,60,"<br>\n"),
            'feed' => $feed + 10,
            'isProductLine' => true,
            'addToTop' => 5,
            'font' => 'regular',
            'font_size' => $fontSize
        ];
    }

    $optionLineCount = 0;
    if (isset($optionText)) {
        $optionLineCount += count($optionText);
    }

    if (isset($bundleText)) {
        $optionLineCount += count($bundleText);
    } 

The result of this is (unwanted result):

RSM-408A: 8-Port Real-time Redundant Ring Switch with metal<br> case (+12 ~ +48 VDC, non-isolation)

Instead of (the desired result):

RSM-408A: 8-Port Real-time Redundant Ring Switch with metal
case (+12 ~ +48 VDC, non-isolation)

Any ideas of what i'm still missing?

0 Answers0