Hello Magento Devs, In today’s tutorial, we are going to learn the Standard way to securely render Javascript inside Magento 2 template files using PHP. While working with Magento 2 template files (.phtml) we are required to use javascript of jQuery code inside the PHTML files. No doubt, Magento 2 is so magical and there …
We can get customer data by injecting “Magento_Customer/js/customer-data” using require function in our custom js/javascript component in Magento 2.
Hello Devs, In this tutorial we are going to see how we can get customer data in a custom js component. We can get customer data by injecting “Magento_Customer/js/customer-data” using require function in our custom js/javascript component in Magento 2. After injecting the object, we can use customerData.get(‘customer’) to get customer information if the customer …
You can use the JQuery library in Magento 2 by adding code inside require function and you can also access it in the console by $ sign.