Skip to content

Commit

Permalink
fixed currency formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
artemis-prime committed Mar 7, 2024
1 parent 5d26982 commit a84d420
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/commerce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hanzo/commerce",
"version": "1.1.7",
"version": "1.1.8",
"description": "Library with shopping cart components.",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
5 changes: 4 additions & 1 deletion packages/commerce/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ export function unslugify(str: string) {
return str.replace(/-/g, ' ')
}


export function formatPrice(price: number): string {
return price.toLocaleString('en-US', {
const str = price.toLocaleString('en-US', {
style: 'currency',
currency: 'USD',
});
return (str.endsWith('.00')) ? str.replace('.00', '') : str
}


export { default as useSyncSkuParamWithCurrentItem } from './use-sync-sku-param-w-current-item'
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { useCommerce } from '../service/context'
import type { FacetsValue } from '../types'

const PLEASE_SELECT_FACETS = 'Please select an option from each group above.'
const PLEASE_SELECT_FACETS = 'Please select an option from each group.'

const useSyncSkuParamWithCurrentItem = (
categoryLevel: number,
Expand Down

0 comments on commit a84d420

Please sign in to comment.