本文整理汇总了PHP中Price::format方法的典型用法代码示例。如果您正苦于以下问题:PHP Price::format方法的具体用法?PHP Price::format怎么用?PHP Price::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Price
的用法示例。
在下文中一共展示了Price::format方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addArrangementShortcode
/**
* Add the [recras-arrangement] shortcode
*
* @param array $attributes
*
* @return string
*/
public static function addArrangementShortcode($attributes)
{
if (!isset($attributes['id'])) {
return __('Error: no ID set', Plugin::TEXT_DOMAIN);
}
if (!ctype_digit($attributes['id'])) {
return __('Error: ID is not a number', Plugin::TEXT_DOMAIN);
}
if (!isset($attributes['show'])) {
return __('Error: "show" option not set', Plugin::TEXT_DOMAIN);
}
if (!in_array($attributes['show'], self::getValidOptions())) {
return __('Error: invalid "show" option', Plugin::TEXT_DOMAIN);
}
$subdomain = Settings::getSubdomain($attributes);
if (!$subdomain) {
return Plugin::getNoSubdomainError();
}
$json = get_transient('recras_' . $subdomain . '_arrangement_' . $attributes['id']);
if ($json === false) {
try {
$json = Http::get($subdomain, 'arrangementen/' . $attributes['id']);
} catch (\Exception $e) {
return $e->getMessage();
}
set_transient('recras_' . $subdomain . '_arrangement_' . $attributes['id'], $json, 86400);
}
switch ($attributes['show']) {
case 'description':
return $json->uitgebreide_beschrijving;
case 'duration':
return self::getDuration($json);
case 'image_url':
return $json->image_filename;
case 'location':
return self::getLocation($json);
case 'persons':
return '<span class="recras-persons">' . $json->aantal_personen . '</span>';
case 'price_pp_excl_vat':
return Price::format($json->prijs_pp_exc);
case 'price_pp_incl_vat':
return Price::format($json->prijs_pp_inc);
case 'price_total_excl_vat':
return Price::format($json->prijs_totaal_exc);
case 'price_total_incl_vat':
return Price::format($json->prijs_totaal_inc);
case 'program':
case 'programme':
$startTime = isset($attributes['starttime']) ? $attributes['starttime'] : '00:00';
$showHeader = !isset($attributes['showheader']) || Settings::parseBoolean($attributes['showheader']);
return self::generateProgramme($json->programma, $startTime, $showHeader);
case 'title':
return '<span class="recras-title">' . $json->arrangement . '</span>';
default:
return __('Error: unknown option', Plugin::TEXT_DOMAIN);
}
}
示例2: addProductShortcode
/**
* Add the [recras-product] shortcode
*
* @param array $attributes
*
* @return string
*/
public static function addProductShortcode($attributes)
{
if (!isset($attributes['id'])) {
return __('Error: no ID set', Plugin::TEXT_DOMAIN);
}
if (!ctype_digit($attributes['id'])) {
return __('Error: ID is not a number', Plugin::TEXT_DOMAIN);
}
if (!isset($attributes['show'])) {
return __('Error: "show" option not set', Plugin::TEXT_DOMAIN);
}
if (!in_array($attributes['show'], self::getValidOptions())) {
return __('Error: invalid "show" option', Plugin::TEXT_DOMAIN);
}
$subdomain = Settings::getSubdomain($attributes);
if (!$subdomain) {
return Plugin::getNoSubdomainError();
}
$products = self::getProducts($subdomain);
if (!isset($products[$attributes['id']])) {
return __('Error: product does not exist', Plugin::TEXT_DOMAIN);
}
$product = $products[$attributes['id']];
switch ($attributes['show']) {
case 'description':
return '<span class="recras-description">' . $product->beschrijving . '</span>';
case 'description_long':
if ($product->uitgebreide_omschrijving) {
return '<span class="recras-description">' . $product->uitgebreide_omschrijving . '</span>';
} else {
return '';
}
case 'duration':
if ($product->duur) {
return '<span class="recras-duration">' . $product->duur . '</span>';
} else {
return '';
}
case 'image_url':
return $product->image_url;
case 'minimum_amount':
return '<span class="recras-amount">' . $product->minimum_aantal . '</span>';
case 'price_excl_vat':
return Price::format($product->prijs_exc);
case 'price_incl_vat':
return Price::format($product->prijs_inc);
case 'title':
return '<span class="recras-title">' . $product->weergavenaam . '</span>';
default:
return __('Error: unknown option', Plugin::TEXT_DOMAIN);
}
}