Utils module
- Source:
Members
(static) FilterResult
Utils of Filter tree
- Source:
- See:
(static) FilterTree
Utils of Filter tree
- Source:
- See:
(static) InstantSearch
Utils of Instant search
- Source:
- See:
Example
var isFullWidth = Utils.InstantSearch.isFullWidthMobile();
Methods
(inner) capitalize(string, isLoweropt, onlyFirstLetteropt)
Capitalize a string
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
String | The string that needs to Capitalize | |
isLower |
Boolean |
<optional> |
Set true if needs to Lowercase all before Capitalize |
onlyFirstLetter |
Boolean |
<optional> |
Set true if just needs to Capitalize the first character |
- Source:
(inner) checkExistBCParam()
Check whether the Boost params exist
- Source:
(inner) convertObjectToArray(obj)
Convert a object to array
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The Object that needs to convert |
- Source:
(inner) convertPriceBasedOnActiveCurrency(price, isRounded)
Convert price to the active currency
Parameters:
Name | Type | Description |
---|---|---|
price |
Number | The product price |
isRounded |
Boolean | TRUE if want to apply rounding rule |
- Source:
(inner) escape(string, preserveCR)
Escape a HTML string to displayed it
Parameters:
Name | Type | Description |
---|---|---|
string |
String | A string that contains HTML element. |
preserveCR |
Boolean | Set true if the end of line is carriage returns |
- Source:
(inner) findIndexArray(findValue, arr, key, sensitive)
Find index of a value in array
Parameters:
Name | Type | Description |
---|---|---|
findValue |
String | The searched value |
arr |
Array | The Array |
key |
String | The searched key |
sensitive |
Boolean | Set true for case sensitive |
- Source:
(inner) formatMoney(money, formatopt, withoutTrailingZerosopt)
Format money based on setting in Shopify
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
money |
String | The money number | |
format |
String |
<optional> |
The format string of Money: - {{ amount }}: $1,999.99 - {{ amount_no_decimals }}: $1,999 - {{ amount_with_comma_separator }}: 1.999,99₫ - {{ amount_no_decimals_with_comma_separator }}: 1.999₫ - {{ amount_with_space_separator_no_comma }}: $1,999.99 |
withoutTrailingZeros |
Boolean |
<optional> |
Disable decimals number if it is zero |
- Source:
(inner) formatNumberWithSeparator(number, precision, thousand, decimal, withoutTrailingZeros) → {string}
Format a number separator
Parameters:
Name | Type | Description |
---|---|---|
number |
Number | Number to Format |
precision |
Number | Integer. |
thousand |
string | Thousand separator |
decimal |
string | Decimal separator |
withoutTrailingZeros |
boolean | Removes .00 or .0 |
- Source:
Returns:
- Type
- string
(inner) getCurrency()
Get currency symbol of store
- Source:
Example
Utils.getCurrency('<span class="money">${{amount}}</span>');
// return '$'
(inner) getFilePath(fileName, extension, version)
Get file path
Parameters:
Name | Type | Description |
---|---|---|
fileName |
String | The file mane |
extension |
* | The file extension |
version |
* | The version of file |
- Source:
(inner) getNumberDecimals(n)
Retrieve number of decimals
Parameters:
Name | Type | Description |
---|---|---|
n |
Number | The number that needs to get decimals |
- Source:
(inner) getParam(name, urlopt)
Get the URL param by name from URL
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String | The name of URL param | |
url |
String |
<optional> |
The URL that needs to get param |
- Source:
(inner) getRoundingRange(isMax)
Get Range of rounding
Parameters:
Name | Type | Description |
---|---|---|
isMax |
Boolean | TRUE if want to return the max value or range |
- Source:
(inner) getSearchTerm()
Get the current search term
- Source:
(inner) getValueInObjectArray(findValue, arr, findKey, destKey)
Get a value of an attribute in an element of an array of object
Parameters:
Name | Type | Description |
---|---|---|
findValue |
String | The searched value |
arr |
Array | The Array |
findKey |
String | The searched key |
destKey |
String |
- Source:
(inner) isBackButton()
Check if page is loaded by back button
- Source:
(inner) isCartPage()
Check if the current page is Cart page
- Source:
(inner) isCollectionParam(type)
Chech whether collection param exist
Parameters:
Name | Type | Description |
---|---|---|
type |
String | Type of filter option |
- Source:
(inner) isEnableShopifyMultipleCurrencies()
Return whether or not Shopify Multi-currencies is enabled
- Source:
(inner) isFloat(n)
Check if the number is Float
Parameters:
Name | Type | Description |
---|---|---|
n |
Number |
- Source:
(inner) isGLHMobile()
Check if app is loaded in google lighthouse mobile
- Source:
(inner) isInt(n)
Check if the number is Interger
Parameters:
Name | Type | Description |
---|---|---|
n |
Number | The number value |
- Source:
(inner) isiOS()
Check if a device is iOS or not
- Source:
(inner) isMobile()
Return true if the screen-width lesser then mobile break-point
- Source:
(inner) isMobileDevice()
Check if the devivce is Mobile Device or not
- Source:
(inner) isProductPage()
Check if the current page is Product page
- Source:
(inner) isSafari()
Check if a browser is Safari or not
- Source:
(inner) isSearchPage()
Check if the current page is Search page
- Source:
(inner) isShopifyActiveCurrency()
Return true if the active currency is not default
- Source:
(inner) isTagPage()
Check if the current page is Tag page
- Source:
(inner) isTypePage()
Check if the current page is Type page
- Source:
(inner) isVendorPage()
Check if the current page is Vendor page
- Source:
(inner) reBuildUrlBaseOnLocale(url)
Re-Build URL with locale
Parameters:
Name | Type | Description |
---|---|---|
url |
String | The URL |
- Source:
(inner) removeCurrencySymbol(price) → {String}
Remove currency symbol from price
Parameters:
Name | Type | Description |
---|---|---|
price |
String | The price string |
- Source:
Returns:
The price string without currency
- Type
- String
(inner) removeDecimal(value, delimiter)
Remove decimals from a number
Parameters:
Name | Type | Description |
---|---|---|
value |
String | Number | The number value |
delimiter |
String | Delimiter symbol |
- Source:
(inner) revertPriceToDefaultCurrency(price, isMin)
Revert price to the default currency
Parameters:
Name | Type | Description |
---|---|---|
price |
Number | The product price |
isMin |
Boolean | TRUE if revert price based on the min-range of rounding |
- Source:
(inner) roundedPrice(price)
Apply shopify rounding rule to product pice
Parameters:
Name | Type | Description |
---|---|---|
price |
Number | the product price |
- Source:
(inner) slugify(text)
Slugify a string (convert a string to slug)
Parameters:
Name | Type | Description |
---|---|---|
text |
String | The string that need to slugify |
- Source:
(inner) sortArrayObject(arr, field)
Sort array of object by field
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | The array that needs to sort |
field |
* | The field of array which will be sorted by |
- Source:
(inner) stripHtml(string)
Strip all HTML tags from a string
Parameters:
Name | Type | Description |
---|---|---|
string |
String | The string that contains HTML tags |
- Source:
(inner) stripScriptTag(string)
Remove all Script in a string
Parameters:
Name | Type | Description |
---|---|---|
string |
String | The string that contains Script tags |
- Source:
(inner) textify(slug, divide)
Convert a slug to string
Parameters:
Name | Type | Description |
---|---|---|
slug |
String | The slug string |
divide |
String | The divide character |
- Source:
(inner) truncateByWord(str, limit, delimiter) → {*}
Add ellipsis to too long text (keep whole word)
Parameters:
Name | Type | Description |
---|---|---|
str |
||
limit |
||
delimiter |
- Source:
Returns:
- Type
- *
(inner) uniq(arr)
Removes duplicate values from an array
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | The array value |
- Source: