Skip to main content
2 of 2
added 515 characters in body
Arthanis
  • 107
  • 1
  • 9

The problem was that the price-box widget was called this way in the module-catalog/view/frontend/templates/product/view/form.phtml:

priceBoxes.priceBox({'priceConfig': <?= /* @escapeNotVerified */ $block->getJsonConfig() ?>});

in this script section:

var dataPriceBoxSelector = '[data-role=priceBox]',
    dataProductIdSelector = '[data-product-id=<?= $block->escapeHtml($_product->getId()) ?>]',
    priceBoxes = $(dataPriceBoxSelector + dataProductIdSelector);

priceBoxes = priceBoxes.filter(function(index, elem){
    return !$(elem).find('.price-from').length;
});

priceBoxes.priceBox({'priceConfig': <?= /* @escapeNotVerified */ $block->getJsonConfig() ?>});

If you override this template and call the priceBox widget this way, it works:

<script type="text/x-magento-init">
    {
        "[data-role=priceBox]": {
            "Magento_Catalog/js/price-box": {
                "priceConfig":  <?= /* @escapeNotVerified */ $block->getJsonConfig() ?>
            }
        }
    }
</script>

With this way, you can't filter the price boxes.

Arthanis
  • 107
  • 1
  • 9