I use the grouped product feature. I use the code below to list the price;

$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); ?>

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?

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.