本文整理汇总了PHP中formatPrice函数的典型用法代码示例。如果您正苦于以下问题:PHP formatPrice函数的具体用法?PHP formatPrice怎么用?PHP formatPrice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatPrice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadCartTotals
static function loadCartTotals($db, $customer_id)
{
$totals = [];
$sql = 'SELECT SUM(product_price * cart_count) AS p FROM viewProductsInCart WHERE cart_customer_id = ?';
$statement = SqlQuery::executeSQL($db, $sql, [$customer_id]);
$result = $statement->get_result();
if ($row = $result->fetch_assoc()) {
$totals = $row;
$selected_currency = Currency::getSelectedCurrency($db);
$totals['pf'] = formatPrice($row['p'], $selected_currency);
$totals['pc'] = $row['p'] / $selected_currency->fval('currency_value');
}
$statement->close();
return $totals;
}
示例2: loadProducts
function loadProducts()
{
global $mysqli;
$p = array();
$res = $mysqli->query("select id, title, description, category, price, image from jube_items order by id");
while ($row = $res->fetch_assoc()) {
if (!$p[$row["category"]]) {
$p[$row["category"]] = array();
}
$item = array("id" => $row["id"], "title" => $row["title"], "description" => $row["description"], "price" => formatPrice($row["price"]), "category" => $row["category"]);
if (!empty($row["image"])) {
$item["thumb"] = PUBLIC_MEDIA_DIR . $row["image"] . "/size_thumb.jpg";
$item["large"] = PUBLIC_MEDIA_DIR . $row["image"] . "/size_large.jpg";
}
$p[$row["category"]][] = $item;
}
$res = array();
$catIndex = 0;
while (list($key, $val) = each($p)) {
$res[] = array("category" => $key, "items" => $val, "catIndex" => $catIndex++);
}
return $res;
}
示例3: EfrontLesson
$smarty->assign('T_CONTACT_FORM', $renderer->toArray());
}
/* -------------------------------------------------------End of Contact part--------------------------------------------------------- */
/* -------------------------------------------------------Lesson information part--------------------------------------------------------- */
if (isset($_GET['ctg']) && $_GET['ctg'] == 'lesson_info') {
//The user asked to display information on a lesson
//session_start(); //Isn't needed here if the head session_start() is in place
if (!$smarty->is_cached('index.tpl', $cacheId) || !$GLOBALS['configuration']['smarty_caching']) {
include "directions_tree.php";
try {
if (isset($_GET['lessons_ID'])) {
if (isset($lessons[$_GET['lessons_ID']]) && $lessons[$_GET['lessons_ID']] instanceof EfrontLesson) {
$smarty->assign("T_HAS_LESSON", $lessons[$_GET['lessons_ID']]->lesson['has_lesson']);
}
$lesson = new EfrontLesson($_GET['lessons_ID']);
$lesson->lesson['price_string'] = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true);
$lesson->lesson['num_students'] = sizeof($lesson->getStudentUsers());
$lesson->lesson['seats_remaining'] = $lesson->lesson['max_users'] - $lesson->lesson['num_students'];
$lesson->lesson['seats_remaining'] >= 0 or $lesson->lesson['seats_remaining'] = 0;
$smarty->assign("T_LESSON", $lesson);
$lessonInformation = $lesson->getInformation();
$content = new EfrontContentTree($lesson);
if (sizeof($content->tree) > 0) {
$smarty->assign("T_CONTENT_TREE", $content->toHTML(false, 'dhtml_content_tree', array('noclick' => 1)));
}
$lessonInfo = new LearningObjectInformation(unserialize($lesson->lesson['info']));
$smarty->assign("T_LESSON_INFO", $lessonInfo);
$additionalInfo = $lesson->getInformation();
$smarty->assign("T_ADDITIONAL_LESSON_INFO", $additionalInfo);
if ($lesson->lesson['course_only']) {
$smarty->assign("T_LESSON_COURSES", $lesson->getCourses());
示例4: buildPriceString
/**
* Build the price string. This function takes the lesson price and
* creates a human-readable version, based on whether it is a one-time
* or a recurring price
*
* @since 3.6.1
* @access protected
*/
private function buildPriceString()
{
if (!empty($this->lesson['price']) && $this->validateFloat($this->lesson['price'])) {
//Create the string representing the lesson price
$this->options['recurring'] ? $recurring = array($this->options['recurring'], $this->options['recurring_duration']) : ($recurring = false);
$this->lesson['price_string'] = formatPrice($this->lesson['price'], $recurring);
} else {
$this->lesson['price_string'] = formatPrice(0);
}
if (mb_strlen($this->lesson['name']) > 100) {
$this->lesson['formatted_name'] = mb_substr($this->lesson['name'], 0, 100) . '...';
} else {
$this->lesson['formatted_name'] = $this->lesson['name'];
}
}
示例5: getListView
public function getListView($lang)
{
require ROOT . "resources/" . $lang . ".php";
$itemHtml = "<div class=\"list-article\">";
$itemHtml .= "<img src=\"" . $this->getImage() . "\" width=\"100px\" height=\"100px\"/>";
$itemHtml .= "<h2>" . $this->getName() . "</h2>";
$itemHtml .= "<p class=\"list-article-price\">{$priceLabel}: " . formatPrice($this->getPrice()) . " CHF</p>";
if (count($this->getVariants()) > 0) {
$itemHtml .= "<p class=\"list-article-variation\">{$variationsLabel}:";
$firstElement = TRUE;
foreach ($this->getVariants() as $variant) {
if ($firstElement) {
$firstElement = FALSE;
} else {
$itemHtml .= ",";
}
if ($variant->getPrice() >= 0) {
$sign = " +";
} else {
$sign = " ";
}
$itemHtml .= " " . $variant->getName() . $sign . formatPrice($variant->getPrice()) . " CHF";
}
$itemHtml .= "</p>";
}
$itemHtml .= "<p>" . $this->getDescription() . "</p>";
$itemHtml .= "<form action=\"index.php\" method=\"get\">";
$itemHtml .= "<input type=\"hidden\" name=\"site\" value=\"article\" /input>";
$itemHtml .= "<input type=\"hidden\" name=\"lang\" value=\"" . $lang . "\" /input>";
$itemHtml .= "<input type=\"hidden\" name=\"artId\" value=\"" . $this->getId() . "\" /input>";
$itemHtml .= "<input class=\"list-article-button\" type=\"submit\" value=\"{$basketButtonLabel}\"/>";
$itemHtml .= "</form>";
$itemHtml .= "</div>";
return $itemHtml;
}
示例6: showCoursePrice
private function showCoursePrice($course)
{
if ($course->course['price']) {
$course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false);
} elseif (!EfrontUser::isOptionVisible('payments')) {
$priceString = '';
} else {
$priceString = _FREECOURSE;
}
return $priceString;
}
示例7: editOrderItemSearchAction
private function editOrderItemSearchAction()
{
if(empty($_REQUEST['q']) || empty($_REQUEST['quoteSession'])) {
exit;
}
$quote = getClass('ISC_ADMIN_ORDERS')->getQuoteSession($_REQUEST['quoteSession']);
if(!$quote) {
exit;
}
$customerGroupId = $quote->getCustomerGroupId();
$_REQUEST['searchQuery'] = $_REQUEST['q'];
// autocomplete plugin can send a limit which will be at most 11 but internally we limit this to 2-11 and
// reduce it by 1 to get 1-10 and append the 'virtual' item result as #11
$limit = 11;
if (isset($_REQUEST['limit'])) {
$limit = max(2, min(10, (int)$_REQUEST['limit']));
}
$limit--;
$numProducts = 0;
$result = getClass('ISC_ADMIN_PRODUCT')->_getProductList(
0, 'p.prodname', 'asc', $numProducts,
'DISTINCT p.*, '.GetProdCustomerGroupPriceSQL($customerGroupId), 10);
$results = array();
while($product = $this->db->fetch($result)) {
$isConfigurable = false;
if($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) {
$isConfigurable = true;
}
$options = array(
'customerGroup' => $customerGroupId
);
$price = calculateFinalProductPrice($product, $product['prodcalculatedprice'], $options);
$price = formatPrice($price);
$results[] = array(
'id' => $product['productid'],
'name' => $product['prodname'],
'link' => prodLink($product['prodname']),
'sku' => $product['prodcode'],
'isConfigurable' => $isConfigurable,
'price' => $price
);
}
$results[] = array(
'id' => 'virtual',
'virtualName' => $_REQUEST['q'],
'name' => GetLang('AddManualProduct'),
'className' => 'recordContentManual',
'price' => GetLang('AddManualProductHelp'),
);
echo isc_json_encode($results);
}
示例8: foreach
// Set properties on variants
foreach ($variants as $variant) {
// hasOptions
$options = str::split($variant->options());
if (count($options)) {
$variant->hasOptions = true;
} else {
$variant->hasOptions = false;
}
// priceText
if (inStock($variant)) {
$variant->priceText = l::get('buy') . ' ';
if ($saleprice = salePrice($variant)) {
$variant->priceText .= formatPrice($saleprice);
$variant->priceText .= '<del>' . formatPrice($variant->price()->value) . '</del>';
} else {
$variant->priceText .= formatPrice($variant->price()->value);
}
} else {
$variant->priceText = l::get('out-of-stock') . ' ';
if ($saleprice = salePrice($variant)) {
$variant->priceText .= formatPrice($saleprice);
$variant->priceText .= '<del>' . formatPrice($variant->price()->value) . '</del>';
} else {
$variant->priceText .= formatPrice($variant->price()->value);
}
}
}
// Pass variables to the template
return ['tags' => $tags, 'variants' => $variants];
};
示例9: formatPrice
$siblingsQty += $qty;
}
}
// Determine if we are at the maximum quantity
if (inStock($variant) !== true and inStock($variant) <= $item->quantity + $siblingsQty) {
$item->maxQty = true;
} else {
$item->maxQty = false;
}
}
}
// Price text
if ($item->sale_amount) {
$item->priceText = formatPrice($item->sale_amount * $item->quantity) . '<del>' . formatPrice($item->amount * $item->quantity) . '</del>';
} else {
$item->priceText = formatPrice($item->amount * $item->quantity);
}
}
// Get countries
$countries = page('/shop/countries')->children()->invisible();
// Get shipping rates
$shipping_rates = $cart->getShippingRates();
// Set shipping method as a session variable
// Shipping method is an array containing 'title' and 'rate'
$shippingMethods = $cart->getShippingRates();
if (get('shipping')) {
// First option: see if a shipping method was set through a form submission
if (get('shipping') == 'free-shipping') {
$shippingMethod = ['title' => l::get('free-shipping'), 'rate' => 0];
}
foreach ($shippingMethods as $key => $method) {
示例10: eF_getTableDataFlat
if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id') && $_GET['type'] == 'branches') {
$result = eF_getTableDataFlat("module_hcd_course_to_branch mb, module_hcd_branch b", "mb.branches_ID, b.name", "b.branch_ID=mb.branches_ID and mb.courses_ID=" . $_GET['courses_ID']);
$tooltipInfo = '<div class = "infoEntry"><span>' . implode(", ", $result['name']) . "</span><span></span></div>";
echo $tooltipInfo;
exit;
}
if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) {
$course = new EfrontCourse($_GET['courses_ID']);
$courseInformation = $course->getInformation();
if ($courseInformation['professors']) {
foreach ($courseInformation['professors'] as $value) {
$professorsString[] = formatLogin($value['login']);
}
$courseInformation['professors'] = implode(", ", $professorsString);
}
$course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false);
$courseInformation['price_string'] = $priceString;
if ($course->course['max_users']) {
$courseInformation['max_users'] = $course->course['max_users'];
$courseInformation['seats_remaining'] = $courseInformation['max_users'] - sizeof($course->getStudentUsers());
$courseInformation['seats_remaining'] >= 0 or $courseInformation['seats_remaining'] = 0;
}
foreach ($courseInformation as $key => $value) {
if ($value) {
$value = str_replace("\n", "<br />", $value);
switch ($key) {
case 'language':
$GLOBALS['configuration']['onelanguage'] or $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>";
break;
case 'professors':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>";
示例11: formatPrice
"></a>
</td>
<td><div class="inner">
<a href="?page=item-detail&item=<?php
echo $item[$i]['item_id'];
?>
"><h2><?php
echo $item[$i]['title'];
?>
</h2></a>
<figure><?php
echo Db::querySingle('SELECT city_title FROM search_cities_table WHERE city_id=?', $item[$i]['city']);
?>
</figure>
<div class="tag price"><?php
formatPrice($config['currency'], $item[$i]['price'], $config['locale']);
?>
</div>
<?php
if (isset($user['is_admin']) && $user['is_admin'] == 1 && $_GET['page'] == 'tools-items') {
?>
<div class="assigned-person">Created by:
<a href="?page=edit-person&person=<?php
echo $person[$i]['person_id'];
?>
"><?php
echo $person[$i]['person_name'];
?>
</a>
<?php
if ($person[$i]['person_id'] == $_SESSION['user_id']) {
示例12: askInformation
function askInformation()
{
try {
if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
$lesson = new EfrontLesson($_GET['lessons_ID']);
$lessonInformation = $lesson->getInformation();
$languages = EfrontSystem::getLanguages(true);
//$lessonInformation['language'] = $languages[$lesson -> lesson['languages_NAME']];
if ($lessonInformation['professors']) {
foreach ($lessonInformation['professors'] as $value) {
$professorsString[] = $value['name'] . ' ' . $value['surname'];
}
$lessonInformation['professors'] = implode(", ", $professorsString);
}
$lesson->lesson['price'] ? $priceString = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true) : ($priceString = false);
$lessonInformation['price_string'] = $priceString;
// if (!$lessonInformation['price']) {
// unset($lessonInformation['price_string']);
// }
try {
if ($_GET['from_course']) {
$course = new EfrontCourse($_GET['from_course']);
$schedule = $course->getLessonScheduleInCourse($lesson);
if ($schedule['start_date'] || $schedule['end_date']) {
$lessonInformation['from_timestamp'] = $schedule['start_date'];
$lessonInformation['to_timestamp'] = $schedule['end_date'];
} else {
$lessonInformation['from_timestamp'] = $schedule['active_in_lesson'] + 24 * 60 * 60 * $schedule['start_period'];
$lessonInformation['to_timestamp'] = $lessonInformation['from_timestamp'] + 24 * 60 * 60 * $schedule['end_period'];
}
}
} catch (Exception $e) {
}
foreach ($lessonInformation as $key => $value) {
if ($value) {
switch ($key) {
case 'language':
$GLOBALS['configuration']['onelanguage'] or $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>";
break;
case 'professors':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>";
break;
case 'content':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _CONTENTUNITS . "</span><span>: {$value}</span></div>";
break;
case 'tests':
EfrontUser::isOptionVisible('tests') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _TESTS . "</span><span>: {$value}</span></div>" : null;
break;
case 'projects':
EfrontUser::isOptionVisible('projects') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROJECTS . "</span><span>: {$value}</span></div>" : null;
break;
case 'course_dependency':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _DEPENDSON . "</span><span>: {$value}</span></div>";
break;
case 'from_timestamp':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEFROM . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>";
break;
case 'to_timestamp':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEUNTIL . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>";
break;
case 'general_description':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>";
break;
case 'assessment':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>";
break;
case 'objectives':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>";
break;
case 'lesson_topics':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONTOPICS . "</span><span>: {$value}</span></div>";
break;
case 'resources':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>";
break;
case 'other_info':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>";
break;
case 'price_string':
!$lesson->lesson['course_only'] ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>" : null;
break;
default:
break;
}
}
}
if ($string = implode("", $tooltipInfo)) {
echo $string;
} else {
echo _NODATAFOUND;
}
}
if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) {
$course = new EfrontCourse($_GET['courses_ID']);
$courseInformation = $course->getInformation();
$languages = EfrontSystem::getLanguages(true);
if ($courseInformation['professors']) {
foreach ($courseInformation['professors'] as $value) {
$professorsString[] = $value['name'] . ' ' . $value['surname'];
}
//.........这里部分代码省略.........
示例13:
<div class="spaced product">
<div class="row">
<div class="col col-md-6 text-center">
<?php
$product->renderImage('view', 'img-thumbnail');
?>
</div>
<div class="col col-md-6">
<div class="row">
<div class="col col-md-6 text-left">
<h3><?=t('Price') ?></h3>
</div>
<div class="col col-md-6 text-right">
<h3><?=formatPrice($product->val('product_price'), $currency) ?></h3>
</div>
</div>
<div class="row spaced">
<div class="col col-md-6 col-md-offset-6 text-right">
<form class="form-inline">
<input name="product_count" id="prod_count_<?=$product->val('product_id')?>" value="1" type="text" maxlength="2" class="form-control prod-item-count" />
<button class="btn btn-success" onclick="javascript:addProductToCart(<?=$product->val('product_id')?>);return false;"><span class="glyphicon glyphicon-shopping-cart"></span><?=t('Buy')?></button>
</form>
</div>
</div>
</div>
</div>
<div class="row spaced">
示例14: intval
$product_id = intval(_g('product_id'));
$count = intval(_g('count'));
$action = $path[2];
if (isset($custAuth) && $custAuth->isAuth()) {
$cart = new Cart($db);
$cart->load($product_id, $custAuth->customer_id);
if ($cart->is_loaded) {
if ($action == 'add') {
$cart->data['cart_count'] = $cart->val('cart_count') + $count;
} elseif ($action == 'update') {
$cart->data['cart_count'] = $count;
}
} else {
$cart->data['cart_product_id'] = $product_id;
$cart->data['cart_customer_id'] = $custAuth->customer_id;
$cart->data['cart_count'] = $count;
}
if ($cart->val('cart_count') > 0) {
$cart->save();
} else {
$cart->deleteById();
}
$data = Cart::loadCartTotals($db, $custAuth->customer_id);
if ($action == 'update') {
$data['ii'] = $product_id;
$product = new Product($db, $product_id);
$data['ip'] = formatPrice($cart->ival('cart_count') * $product->ival('product_price'));
}
} else {
echo 'Cannot authenticate customer';
}
示例15: _url
</a>
<div class="panel-title">
<a href="<?php
echo _url($product->val('alias_url'));
?>
"><?php
echo $product->val('product_name');
?>
</a>
</div>
<div class="product-price">
<div class="price">
<?php
echo formatPrice($product->val('product_price'));
?>
</div>
</div>
</div>
<div class="panel-heading basic-bg text-right">
<form class="form-inline">
<input id="prod_count_<?php
echo $product->val('product_id');
?>
" value="1" type="text" maxlength="2" class="form-control prod-item-count" />
<button class="btn btn-success" onclick="javascript:addProductToCart(<?php
echo $product->val('product_id');
?>