PHP code example of jtn / shopify-currency-format
1. Go to this page and download the library: Download jtn/shopify-currency-format library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jtn / shopify-currency-format example snippets
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>
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 :(