<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * Template for displaying grouped product price
 */
?>
<?php
$minProduct = $block->getSaleableItem()
    ->getPriceInfo()
    ->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)
    ->getMinProduct();

if ($minProduct) {
    $amountRender = $block->getRendererPool()
        ->createAmountRender(
            $minProduct->getPriceInfo()->getPrice('final_price')->getAmount(),
            $minProduct,
            $minProduct->getPriceInfo()->getPrice('final_price'),
            ['include_container' => true, 'grouped' => true, 'product' => $block->getSaleableItem()]
        );

    $productCount = count($block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem()));
}
?>
<div class="price-box">
    <?php if ($minProduct && \Magento\Framework\Pricing\Render::ZONE_ITEM_VIEW != $block->getZone()) : ?>
    <p class="minimal-price">
        <span class="price-label"><?php if ($productCount > 1) : ?><?= $block->escapeHtml(__('Starting at')) ?><?php endif ?></span><?= $amountRender->toHtml() ?>
    </p>
    <?php endif ?>
</div>
