定制 jtn/shopify-currency-format 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jtn/shopify-currency-format

最新稳定版本:v1.0.0

Composer 安装命令:

composer require jtn/shopify-currency-format

包简介

Helper for formatting string to fit Shopify currency formats

README 文档

README

Build Status

This is a small helper utility for formatting currencies provided by the Shopify API. All the formats covered in the documentation on Shopify currency formats are supported

Installation

Install with composer.

composer require jtn/shopify-currency-format

Usage

Simply create a new instance of the class and supply the format you want to use and pass an integer in cents to the format method.

If you pass a string the library will expect this came from the Shopify API so will be in dollars and cents so it will be divided by 100.

You can change the format by calling setFormat.

use Jtn\ShopifyCurrencyFormat\ShopifyCurrencyFormat;

$formatter = new ShopifyCurrencyFormat('{{ amount_no_decimals }}');
echo $formatter->format(3.65); // 4

$formatter->setFormat('{{ amount_no_decimals }}');
echo $formatter->format(300); // 3.00

$formatter->setFormat('<span class=money>£{{ amount }} GBP</span>');
echo $formatter->format('5.99'); // <span class=money>£5.99 GBP</span>

If you specifiy an unsupported format an exception will be thrown.

use Jtn\ShopifyCurrencyFormat\ShopifyCurrencyFormat;
use Jtn\ShopifyCurrencyFormat\UnsupportedFormatException;

$formatter = new ShopifyCurrencyFormat('{{ some_unsupported_format }}');

try {
	echo $formatter->format(1.00);
} catch(UnsupportedFormatException $e) {
	echo 'That format is not supported :(';
}

// That format is not supported :(

统计信息

  • 总下载量: 263
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-06