I use the grouped product feature. I use the code below to list the price;
<?php
$priceHelper = $this->helper(\Magento\Framework\Pricing\Helper\Data::class);
$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getFinalPrice();
}
?>
<div class="price-box price-final_price">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll ?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price">
<?= $priceHelper->currency($priceForAll, true, false); ?>
</span>
</span>
</span>
</div>
I want the price of the main product to update automatically when the quantity of products change in the group. How can I do that?