Skip to main content
added 515 characters in body
Source Link
Arthanis
  • 107
  • 1
  • 9

The Problem:

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() ?>});

But ifin 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.

The Problem:

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() ?>});

But 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>

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.

Source Link
Arthanis
  • 107
  • 1
  • 9

The Problem:

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() ?>});

But 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>