Socket
Socket
Sign inDemoInstall

@woocommerce/currency

Package Overview
Dependencies
51
Maintainers
18
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @woocommerce/currency

WooCommerce currency utilities.


Version published
Weekly downloads
919
decreased by-11.72%
Maintainers
18
Install size
10.7 MB
Created
Weekly downloads
 

Readme

Source

Currency

A collection of utilities to display and work with currency values.

Installation

Install the module

pnpm install @woocommerce/currency --save

This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods. Learn more about it in Babel docs.

Usage

import CurrencyFactory from '@woocommerce/currency';

const storeCurrency = CurrencyFactory(); // pass store settings into constructor.

// Formats money with a given currency symbol. Uses site's currency settings for formatting,
// from the settings api. Defaults to symbol=`$`, precision=2, decimalSeparator=`.`, thousandSeparator=`,`
const total = storeCurrency.formatAmount( 20.923 ); // '$20.92'

// Get the rounded decimal value of a number at the precision used for the current currency,
// from the settings api. Defaults to 2.
const total = storeCurrency.formatDecimal( '6.2892' ); // 6.29

// Get the string representation of a floating point number to the precision used by the current
// currency. This is different from `formatAmount` by not returning the currency symbol.
const total = storeCurrency.formatDecimalString( 1088.478 ); // '1088.48'

Keywords

FAQs

Last updated on 08 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc