本文整理匯總了PHP中Money::Nice方法的典型用法代碼示例。如果您正苦於以下問題:PHP Money::Nice方法的具體用法?PHP Money::Nice怎麽用?PHP Money::Nice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Money
的用法示例。
在下文中一共展示了Money::Nice方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Description
/**
* Return the amount for this tax rate for displaying in the {@link CheckoutForm}
*
* @return String
*/
public function Description()
{
return $this->amount->Nice();
}
開發者ID:helpfulrobot,項目名稱:swipestripe-swipestripe-flatfeeshipping,代碼行數:9,代碼來源:FlatFeeShippingModifierField.php
示例2: testToCurrency
public function testToCurrency()
{
$USD = new Money();
$USD->setCurrency('USD');
$USD->setLocale('en_US');
$EGP = new Money();
$EGP->setCurrency('EGP');
$EGP->setLocale('ar_EG');
$USD->setAmount(53292.18);
$this->assertSame('$53,292.18', $USD->Nice());
$USD->setAmount(53292.18);
$this->assertSame('$٥٣,٢٩٢.١٨', $USD->Nice(array('script' => 'Arab')));
$USD->setAmount(53292.18);
$this->assertSame('$ ٥٣.٢٩٢,١٨', $USD->Nice(array('script' => 'Arab', 'format' => 'de_AT')));
$USD->setAmount(53292.18);
$this->assertSame('$ 53.292,18', $USD->Nice(array('format' => 'de_AT')));
$EGP->setAmount(53292.18);
$this->assertSame('ج.م. 53٬292٫18', $EGP->Nice());
$EGP->setAmount(53292.18);
$this->assertSame('ج.م. ٥٣٬٢٩٢٫١٨', $EGP->Nice(array('script' => 'Arab')));
$EGP->setAmount(53292.18);
$this->assertSame('ج.م. ٥٣.٢٩٢,١٨', $EGP->Nice(array('script' => 'Arab', 'format' => 'de_AT')));
$EGP->setAmount(53292.18);
$this->assertSame('ج.م. 53.292,18', $EGP->Nice(array('format' => 'de_AT')));
$USD = new Money();
$USD->setLocale('en_US');
$USD->setAmount(53292.18);
$this->assertSame('$53,292.18', $USD->Nice());
/*
try {
$this->assertSame('$ 53,292.18', $USD->Nice('nocontent'));
$this->fail("No currency expected");
} catch (Exception $e) {
$this->assertContains("has to be numeric", $e->getMessage());
}
*/
$INR = new Money();
$INR->setLocale('de_AT');
$INR->setCurrency('INR');
$INR->setAmount(1.2);
$this->assertSame('Rs. 1,20', $INR->Nice());
$INR->setAmount(1);
$this->assertSame('Re. 1,00', $INR->Nice());
$INR->setAmount(0);
$this->assertSame('Rs. 0,00', $INR->Nice());
$INR->setAmount(-3);
$this->assertSame('-Rs. 3,00', $INR->Nice());
}
示例3: getPositionsAsString
/**
* Returns the Order Positions as a string.
*
* @param bool $asHtmlString Set to true to use HTML inside the string.
* @param bool $withAmountTotal Set to true add the orders total amount.
*
* @return string
*/
public function getPositionsAsString($asHtmlString = false, $withAmountTotal = false)
{
if ($asHtmlString) {
$seperator = '<br/>';
} else {
$seperator = PHP_EOL;
}
$positionsStrings = array();
foreach ($this->SilvercartOrderPositions() as $position) {
$positionsString = $position->getTypeSafeQuantity() . 'x #' . $position->ProductNumber . ' "' . $position->Title . '" ' . $position->getPriceTotalNice();
$positionsStrings[] = $positionsString;
}
$positionsAsString = implode($seperator . '------------------------' . $seperator, $positionsStrings);
if ($withAmountTotal) {
$shipmentAndPayment = new Money();
$shipmentAndPayment->setAmount($this->HandlingCostPayment->getAmount() + $this->HandlingCostShipment->getAmount());
$shipmentAndPayment->setCurrency($this->HandlingCostPayment->getCurrency());
$positionsAsString .= $seperator . '------------------------' . $seperator;
$positionsAsString .= $this->fieldLabel('HandlingCost') . ': ' . $shipmentAndPayment->Nice() . $seperator;
$positionsAsString .= '________________________' . $seperator . $seperator;
$positionsAsString .= $this->fieldLabel('AmountTotal') . ': ' . $this->AmountTotal->Nice();
}
return $positionsAsString;
}
示例4: testToCurrency
public function testToCurrency()
{
$USD = new Money();
$USD->setLocale('en_US');
$USD->setAmount(53292.18);
$this->assertSame('$53,292.18', $USD->Nice());
$this->assertSame('$ 53.292,18', $USD->Nice(array('format' => 'de_AT')));
}
示例5: PriceFormatted
/**
* Returns the Price formatted by locale.
*
* @return string
*
* @author Sascha Koehler <skoehler@pixeltricks.de>
* @since 31.01.2011
*/
public function PriceFormatted()
{
$priceObj = new Money();
$priceObj->setAmount($this->getPriceAmount());
$priceObj->setCurrency($this->price->getCurrency());
return $priceObj->Nice();
}
示例6: variationprice
/**
* Calculate the {@link Variation} price difference based on current request.
* Current seleted options are passed in POST vars, if a matching Variation can
* be found, the price difference of that Variation is returned for display on the Product
* page.
*
* TODO return the total here as well
*
* @param SS_HTTPRequest $request
* @return String JSON encoded string of price difference
*/
function variationprice(SS_HTTPRequest $request)
{
$data = array();
$product = $this->data();
$variations = $product->Variations();
$attributeOptions = $request->postVar('Options');
//Filter variations to match attribute ID and option ID
$variationOptions = array();
if ($variations && $variations->exists()) {
foreach ($variations as $variation) {
$options = $variation->Options();
if ($options) {
foreach ($options as $option) {
$variationOptions[$variation->ID][$option->AttributeID] = $option->ID;
}
}
}
}
$variation = null;
foreach ($variationOptions as $variationID => $options) {
if ($options == $attributeOptions) {
$variation = $variations->find('ID', $variationID);
break;
}
}
$data['totalPrice'] = $product->Amount->Nice();
if ($variation) {
if ($variation->Amount->getAmount() == 0) {
$data['priceDifference'] = 0;
} else {
if ($variation->Amount->getAmount() > 0) {
$data['priceDifference'] = '(+' . $variation->Amount->Nice() . ')';
$newTotal = new Money();
$newTotal->setCurrency($product->Amount->getCurrency());
$newTotal->setAmount($product->Amount->getAmount() + $variation->Amount->getAmount());
$data['totalPrice'] = $newTotal->Nice();
} else {
//Variations have been changed so only positive values, so this is unnecessary
//$data['priceDifference'] = '(' . $variation->Amount->Nice() . ')';
}
}
}
return json_encode($data);
}
示例7: PriceFormatted
/**
* Returns the Price formatted by locale.
*
* @param bool $plain Set to true to load the price amount without any manipulation
*
* @return string
*
* @author Sascha Koehler <skoehler@pixeltricks.de>, Sebastian Diel <sdiel@pixeltricks.de>
* @since 04.04.2012
*/
public function PriceFormatted($plain = false)
{
$priceFormatted = '';
if ($this->PostPricing) {
$priceFormatted = '---';
} else {
$priceObj = new Money();
$priceObj->setAmount($this->getPriceAmount($plain));
$priceObj->setCurrency($this->getPriceCurrency());
$priceFormatted = $priceObj->Nice();
}
return $priceFormatted;
}
示例8: MinimumOrderValue
/**
* Returns the minimum order value.
*
* @return mixed Money
*
* @author Sascha Koehler <skoehler@pixeltricks.de>
* @since 09.06.2011
*/
public function MinimumOrderValue()
{
$minimumOrderValue = new Money();
if (SilvercartConfig::UseMinimumOrderValue() && SilvercartConfig::MinimumOrderValue()) {
$minimumOrderValue->setAmount(SilvercartConfig::MinimumOrderValue()->getAmount());
$minimumOrderValue->setCurrency(SilvercartConfig::MinimumOrderValue()->getCurrency());
}
return $minimumOrderValue->Nice();
}