How to set Price Format using javascript Magento 2.

Format a Price Using Javascript(JS) in Magento 2 for display a price with proper formating.

You have to use ‘Magento_Catalog/js/price-utils’ priceUtils Js Object in your javascript file to set format a price using javascript. Continue reading “How to set Price Format using javascript Magento 2.”

How to get Custom, Base Url in JS file Magento 2?

You can get the custom or base URL of store in javascript(JS) file for frontend area using ‘mage/url’ widgets.

You have to pass ‘mage/url’ widget as a dependency in a define([]) or require([]) function of the javascript file. Continue reading “How to get Custom, Base Url in JS file Magento 2?”

Check Customer isLogged in using knockout js magento 2.

You can check customer is logged in or using knockout javascript in Magento 2 by using ‘Magento_Customer/js/model/customer’ class.

customer.js file used to check customer is logged in or not.

Above Js file contains the method isLoggedIn() to detect customer login status.

Output: Boolean Continue reading “Check Customer isLogged in using knockout js magento 2.”