Composable Commerce PHP SDKPHP SDK
  • Namespace
  • Class
  • Tree

Namespaces

  • Commercetools
    • Commons
      • Helper
    • Core
      • Builder
        • Request
        • Update
      • Cache
      • Client
        • Adapter
        • OAuth
      • Error
      • Helper
        • Annotate
        • State
          • Renderer
        • Subscriber
          • Log
      • Model
        • ApiClient
        • Cart
        • CartDiscount
        • Category
        • Channel
        • Common
        • Customer
        • CustomerGroup
        • CustomField
        • CustomObject
        • DiscountCode
        • Extension
        • Inventory
        • Message
        • Order
        • OrderEdit
        • Payment
        • Product
          • Search
        • ProductDiscount
        • ProductSelection
        • ProductType
        • Project
        • Review
        • ShippingMethod
        • ShoppingList
        • State
        • Store
        • Subscription
        • TaxCategory
        • Type
        • Zone
      • Request
        • ApiClients
        • CartDiscounts
          • Command
        • Carts
          • Command
        • Categories
          • Command
        • Channels
          • Command
        • CustomerGroups
          • Command
        • Customers
          • Command
        • CustomField
          • Command
        • CustomObjects
        • DiscountCodes
          • Command
        • Extensions
          • Command
        • GraphQL
        • InStores
        • Inventory
          • Command
        • Me
          • Command
        • Messages
        • OrderEdits
          • Command
          • StagedOrder
            • Command
        • Orders
          • Command
        • Payments
          • Command
        • ProductDiscounts
          • Command
        • Products
          • Command
        • ProductSelections
          • Command
        • ProductTypes
          • Command
        • Project
          • Command
        • Query
        • Reviews
          • Command
        • ShippingMethods
          • Command
        • ShoppingLists
          • Command
        • States
          • Command
        • Stores
          • Command
        • Subscriptions
          • Command
        • TaxCategories
          • Command
        • Types
          • Command
        • Zones
          • Command
      • Response

Classes

  • CurrencyFormatter
  • DefaultCorrelationIdProvider
  • Uuid

Interfaces

  • CorrelationIdProvider
  • CurrencyFormatterInterface

Class CurrencyFormatter

Formats a given currency for display. As default the intl extensions capabilities are used for formatting. Given the locale of the context and the currency, the amount will be formatted with intl NumberFormatter. The formatter reads the fraction digits from the formatter for the given currency and locale. This information is used to calculate the currency value from the centAmount

Example: $centAmount = 123456; $currency = 'JPY'; $str = $this->format($centAmount, $currency); // '¥123,456' $currency = 'USD'; $str = $this->format($centAmount, $currency); // '$1,234.56' $currency = 'EUR'; $str = $this->format($centAmount, $currency); // '1.234,56 €'

Commercetools\Core\Helper\CurrencyFormatter implements Commercetools\Core\Helper\CurrencyFormatterInterface
Namespace: Commercetools\Core\Helper
Located at Core/Helper/CurrencyFormatter.php

Methods summary

public
# __construct( Commercetools\Core\Model\Common\Context $context )
public
# setFormatCallback( callable $formatCallback )

Parameters

$formatCallback
public string
# format( integer $centAmount, string $currency )

Parameters

$centAmount
$currency

Returns

string

Implementation of

Commercetools\Core\Helper\CurrencyFormatterInterface::format()
PHP SDK API documentation generated by ApiGen