Methods
-
formatPhone( phone, format ) → {String}
-
Description
Will try to reformat a phone number for a given phone Format. If no format is given, it will try to use the one in site settings.
Parameters
Name Type Description phoneString formatString Returns
-
dateToString( date ) → {String}
-
Description
Converts a date object to string using international format YYYY-MM-dd. Useful for inputs of type="date"
Parameters
Name Type Description dateDate Returns
-
stringToDate( str_date, options )
-
Description
Parse a string date into a date object.
Parameters
Name Type Description str_dateString optionsObject formatis the String format that specify the format of the input string. By Default YYYY-MM-dd.plusMonth: Number that indicate how many month offset should be applied whne creating the date object. -
formatCurrency( value, symbol ) → {String}
-
Description
Formats given number and symbol to a currency like string. Example:
Utils.formatCurrency(10, '£')Parameters
Name Type Description valueString symbolString Returns
-
formatQuantity( number ) → {String}
-
Description
Formats with commas as thousand separator (e.g. for displaying quantities)
Parameters
Name Type Description numberString Returns
-
validateSecurityCode( value )
-
Parameters
Name Type Description valueString Returns
-
validatePhone( phone ) → {String}
-
Parameters
Name Type Description phoneString Returns
-
validateState( value, valName, options ) → {String}
-
Parameters
Name Type Description valueString valNameString optionsObject Returns
-
validateZipCode( value, valName, options ) → {String}
-
Parameters
Name Type Description valueString valNameString optionsObject Returns
-
translate( text )
-
Description
Used on all of the hardcoded texts in the templates. Gets the translated value from SC.Translations object literal.
Please always use the syntax_('string').translate(1, 2)instead of the syntax_.translate('string', 1, 2)if possible.Example using the Utils object:
Utils.translate('There are $(0) apples in the tree', appleCount)Sample example using the
_.translate(underscore mixing):_('There are $(0) apples in the tree').translate(appleCount)See frontend_internationalization
Parameters
Name Type Description textString @return {String}
-
deepCopy( obj, obj )
-
Description
Deep Copy of the object taking care of Backbone models
Parameters
Name Type Description objany objany -
getPathFromObject( object, path [, default_value ] )
-
Description
Gets given object property supporting deep property references by separating names with dots ('.')
Parameters
Name Type Attributes Description objectany The object to get the property from
pathString a path with values separated by dots
default_valueany <optional> value to return if nothing is found.
-
setPathFromObject( object, path, value )
-
Description
Sets given object property supporting deep property references by separating names with dots ('.')
Parameters
Name Type Description objectany the object to modify
pathString a path with values separated by dots
valueany the value to set
-
isShoppingDomain() → {Boolean}
-
Description
Determines if we are in shopping domain (secure or non secure) or single domain
Returns
-
isCheckoutDomain() → {Boolean}
-
Description
Determines if we are in a secure checkout
domain or in a secure single domain environmentReturns
-
isSingleDomain() → {Boolean}
-
Description
Determines if we are in a single domain environment
Returns
-
isInShopping() → {Boolean}
-
Description
Determines if we are in shopping ssp used when there are frontend features only shown in the shopping domain
Returns
-
isInCheckout() → {Boolean}
-
Description
Determines if we are in checkout or my account ssp
Returns
-
getAbsoluteUrl( path ) → {String}
-
Description
returns the absolute URL of given relative path
Parameters
Name Type Description pathString Returns