How do I fix Magento 2.2.2
Cannot Read Property “quoteData” of undefined
Issue? Please give me flexible solution for this issue.
It is almost impossible to identify the source of this error based just on this message. Most likely you are overriding/extending (mixin) some file, which being called on page where it is not intended.
Maybe instead of declaring some of your js library at requirejs, put in view/frontent/templates, as an example bellow.
<?php
$displayOnThisPage = $block->someFunctionWhichReturnsTrueFalse();
?>
<?php if ($block->isCheckoutPage()): ?>
<!--- some html if this is checkout page --->
<?php endif; ?>
<?php if ($displayOnThisPage ): ?>
<script>
require.config({
config: {
mixins: {
'Magento_Ui/js/lib/validation/validator': {
'Vendor_Module/js/validator-mixin': true
}
}
},
map: {
"*": {}
}
});
</script>
<script type="text/x-magento-init">
{
"*": {
<?php if ($block->isCheckoutPage()): ?>
<?php else: ?>
<?php endif; ?>
}
}
</script>
<?php endif; ?>