本文整理汇总了PHP中Currency::formatPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::formatPrice方法的具体用法?PHP Currency::formatPrice怎么用?PHP Currency::formatPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::formatPrice方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: confirm
/**
* Generates an overview of the Order for the Customer to confirm
*
* Forward her to the processing of the Order after the button has been
* clicked.
* @return boolean True on success, false otherwise
*/
static function confirm()
{
global $_ARRAYLANG;
// If the cart or address is missing, return to the shop
if (!self::verifySessionAddress()) {
\Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', ''));
}
self::$show_currency_navbar = false;
// The Customer clicked the confirm button; this must not be the case
// the first time this method is called.
if (isset($_POST['process'])) {
return self::process();
}
// Show confirmation page.
self::$objTemplate->hideBlock('shopProcess');
self::$objTemplate->setGlobalVariable($_ARRAYLANG);
// It may be necessary to refresh the cart here, as the customer
// may return to the cart, then press "Back".
self::_initPaymentDetails();
foreach (Cart::get_products_array() as $arrProduct) {
$objProduct = Product::getById($arrProduct['id']);
if (!$objProduct) {
// TODO: Implement a proper method
// unset(Cart::get_product_id($cart_id]);
continue;
}
$price_options = 0;
$attributes = Attributes::getAsStrings($arrProduct['options'], $price_options);
$attributes = $attributes[0];
// Note: The Attribute options' price is added
// to the price here!
$price = $objProduct->get_custom_price(self::$objCustomer, $price_options, $arrProduct['quantity']);
// Test the distribution method for delivery
$productDistribution = $objProduct->distribution();
$weight = $productDistribution == 'delivery' ? Weight::getWeightString($objProduct->weight()) : '-';
$vatId = $objProduct->vat_id();
$vatRate = Vat::getRate($vatId);
$vatPercent = Vat::getShort($vatId);
$vatAmount = Vat::amount($vatRate, $price * $arrProduct['quantity']);
self::$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CUSTOM_ID' => $objProduct->code(), 'SHOP_PRODUCT_TITLE' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price * $arrProduct['quantity']), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => Currency::formatPrice($price), 'SHOP_UNIT' => Currency::getActiveCurrencySymbol()));
if ($attributes && self::$objTemplate->blockExists('attributes')) {
self::$objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $attributes);
}
if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
self::$objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => $weight, 'TXT_WEIGHT' => $_ARRAYLANG['TXT_WEIGHT']));
}
if (Vat::isEnabled()) {
self::$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $vatPercent, 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($vatAmount) . ' ' . Currency::getActiveCurrencySymbol()));
}
self::$objTemplate->parse("shopCartRow");
}
$total_discount_amount = 0;
if (Cart::get_discount_amount()) {
$total_discount_amount = Cart::get_discount_amount();
self::$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
}
self::$objTemplate->setVariable(array('SHOP_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTALITEM' => Cart::get_item_count(), 'SHOP_PAYMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['payment_price']), 'SHOP_TOTALPRICE' => Currency::formatPrice(Cart::get_price()), 'SHOP_PAYMENT' => Payment::getProperty($_SESSION['shop']['paymentId'], 'name'), 'SHOP_GRAND_TOTAL' => Currency::formatPrice($_SESSION['shop']['grand_total_price']), 'SHOP_COMPANY' => stripslashes($_SESSION['shop']['company']), 'SHOP_TITLE' => stripslashes($_SESSION['shop']['gender']), 'SHOP_GENDER' => stripslashes($_SESSION['shop']['gender']), 'SHOP_LASTNAME' => stripslashes($_SESSION['shop']['lastname']), 'SHOP_FIRSTNAME' => stripslashes($_SESSION['shop']['firstname']), 'SHOP_ADDRESS' => stripslashes($_SESSION['shop']['address']), 'SHOP_ZIP' => stripslashes($_SESSION['shop']['zip']), 'SHOP_CITY' => stripslashes($_SESSION['shop']['city']), 'SHOP_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId']), 'SHOP_EMAIL' => stripslashes($_SESSION['shop']['email']), 'SHOP_PHONE' => stripslashes($_SESSION['shop']['phone']), 'SHOP_FAX' => stripslashes($_SESSION['shop']['fax'])));
if (!empty($_SESSION['shop']['lastname2'])) {
self::$objTemplate->setVariable(array('SHOP_COMPANY2' => stripslashes($_SESSION['shop']['company2']), 'SHOP_TITLE2' => stripslashes($_SESSION['shop']['gender2']), 'SHOP_LASTNAME2' => stripslashes($_SESSION['shop']['lastname2']), 'SHOP_FIRSTNAME2' => stripslashes($_SESSION['shop']['firstname2']), 'SHOP_ADDRESS2' => stripslashes($_SESSION['shop']['address2']), 'SHOP_ZIP2' => stripslashes($_SESSION['shop']['zip2']), 'SHOP_CITY2' => stripslashes($_SESSION['shop']['city2']), 'SHOP_COUNTRY2' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId2']), 'SHOP_PHONE2' => stripslashes($_SESSION['shop']['phone2'])));
}
if (!empty($_SESSION['shop']['note'])) {
self::$objTemplate->setVariable(array('SHOP_CUSTOMERNOTE' => $_SESSION['shop']['note']));
}
if (Vat::isEnabled()) {
self::$objTemplate->setVariable(array('TXT_TAX_RATE' => $_ARRAYLANG['TXT_SHOP_VAT_RATE'], 'SHOP_TAX_PRICE' => Currency::formatPrice($_SESSION['shop']['vat_price']), 'SHOP_TAX_PRODUCTS_TXT' => $_SESSION['shop']['vat_products_txt'], 'SHOP_TAX_GRAND_TXT' => $_SESSION['shop']['vat_grand_txt'], 'TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL']));
if (Vat::isIncluded()) {
self::$objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice($_SESSION['shop']['grand_total_price'] - $_SESSION['shop']['vat_price'])));
}
}
// TODO: Make sure in payment() that those two are either both empty or
// both non-empty!
if (!Cart::needs_shipment() && empty($_SESSION['shop']['shipperId'])) {
if (self::$objTemplate->blockExists('shipping_address')) {
self::$objTemplate->hideBlock('shipping_address');
}
} else {
// Shipment is required, so
if (empty($_SESSION['shop']['shipperId'])) {
\Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment'));
}
self::$objTemplate->setVariable(array('SHOP_SHIPMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['shipment_price']), 'SHOP_SHIPMENT' => Shipment::getShipperName($_SESSION['shop']['shipperId'])));
}
// Custom.
// Enable if Discount class is customized and in use.
//self::showCustomerDiscount(Cart::get_price());
return true;
}
示例2: getSubstitutionArray
//.........这里部分代码省略.........
$product_code = $objProduct->code();
// Pick the order items attributes
$str_options = '';
// Any attributes?
if ($item['attributes']) {
$str_options = ' ';
// '[';
$attribute_name_previous = '';
foreach ($item['attributes'] as $attribute_name => $arrAttribute) {
//DBG::log("Attribute /$attribute_name/ => ".var_export($arrAttribute, true));
// NOTE: The option price is optional and may be left out
foreach ($arrAttribute as $arrOption) {
$option_name = $arrOption['name'];
$option_price = $arrOption['price'];
$item_price += $option_price;
// Recognize the names of uploaded files,
// verify their presence and use the original name
$option_name_stripped = ShopLibrary::stripUniqidFromFilename($option_name);
$path = Order::UPLOAD_FOLDER . $option_name;
if ($option_name != $option_name_stripped && \File::exists($path)) {
$option_name = $option_name_stripped;
}
if ($attribute_name != $attribute_name_previous) {
if ($attribute_name_previous) {
$str_options .= '; ';
}
$str_options .= $attribute_name . ': ' . $option_name;
$attribute_name_previous = $attribute_name;
} else {
$str_options .= ', ' . $option_name;
}
// TODO: Add proper formatting with sprintf() and language entries
if ($option_price != 0) {
$str_options .= ' ' . Currency::formatPrice($option_price) . ' ' . Currency::getActiveCurrencyCode();
}
}
}
// $str_options .= ']';
}
// Product details
$arrProduct = array('PRODUCT_ID' => $product_id, 'PRODUCT_CODE' => $product_code, 'PRODUCT_QUANTITY' => $quantity, 'PRODUCT_TITLE' => $product_name, 'PRODUCT_OPTIONS' => $str_options, 'PRODUCT_ITEM_PRICE' => sprintf('% 9.2f', $item_price), 'PRODUCT_TOTAL_PRICE' => sprintf('% 9.2f', $item_price * $quantity));
//DBG::log("Orders::getSubstitutionArray($order_id, $create_accounts): Adding article: ".var_export($arrProduct, true));
$orderItemCount += $quantity;
$total_item_price += $item_price * $quantity;
if ($create_accounts) {
// Add an account for every single instance of every Product
for ($instance = 1; $instance <= $quantity; ++$instance) {
$validity = 0;
// Default to unlimited validity
// In case there are protected downloads in the cart,
// collect the group IDs
$arrUsergroupId = array();
if ($objProduct->distribution() == 'download') {
$usergroupIds = $objProduct->usergroup_ids();
if ($usergroupIds != '') {
$arrUsergroupId = explode(',', $usergroupIds);
$validity = $objProduct->weight();
}
}
// create an account that belongs to all collected
// user groups, if any.
if (count($arrUsergroupId) > 0) {
// The login names are created separately for
// each product instance
$username = self::usernamePrefix . "_{$order_id}_{$product_id}_{$instance}";
$userEmail = $username . '-' . $arrSubstitution['CUSTOMER_EMAIL'];
示例3: getTotalAmountString
/**
* Returns a formatted string indicating the given amount as discounted
* due to the use of coupon codes
* @param float $amount The amount
* @return sting The formatted string
*/
static function getTotalAmountString($amount)
{
global $_ARRAYLANG;
return sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL_STRING_FORMAT'], Currency::formatPrice($amount), Currency::getActiveCurrencyCode());
}
示例4: view
/**
* The Cart view
*
* Mind that the Cart needs to be {@see update()}d before calling this
* method.
* @global array $_ARRAYLANG Language array
* @param \Cx\Core\Html\Sigma $objTemplate The optional Template
*/
static function view($objTemplate = null)
{
global $_ARRAYLANG;
if (!$objTemplate) {
// TODO: Handle missing or empty Template, load one
die("Cart::view(): ERROR: No template");
// return false;
}
$objTemplate->setGlobalVariable($_ARRAYLANG);
$i = 0;
if (count(self::$products)) {
foreach (self::$products as $arrProduct) {
$groupCountId = $arrProduct['group_id'];
$groupArticleId = $arrProduct['article_id'];
$groupCustomerId = 0;
if (Shop::customer()) {
$groupCustomerId = Shop::customer()->group_id();
}
Shop::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $arrProduct['quantity']);
// product image
$arrProductImg = Products::get_image_array_from_base64($arrProduct['product_images']);
$shopImagesWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesWebPath() . '/Shop/';
$thumbnailPath = $shopImagesWebPath . ShopLibrary::noPictureName;
foreach ($arrProductImg as $productImg) {
if (!empty($productImg['img']) && $productImg['img'] != ShopLibrary::noPictureName) {
$thumbnailPath = $shopImagesWebPath . \ImageManager::getThumbnailFilename($productImg['img']);
break;
}
}
/* UNUSED (and possibly obsolete, too)
if (isset($arrProduct['discount_string'])) {
//DBG::log("Shop::view_cart(): Product ID ".$arrProduct['id'].": ".$arrProduct['discount_string']);
$objTemplate->setVariable(
'SHOP_DISCOUNT_COUPON_STRING',
$arrProduct['coupon_string']
);
}*/
// The fields that don't apply have been set to ''
// (empty string) already -- see update().
$objTemplate->setVariable(array('SHOP_PRODUCT_ROW' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CODE' => $arrProduct['product_id'], 'SHOP_PRODUCT_THUMBNAIL' => $thumbnailPath, 'SHOP_PRODUCT_CART_ID' => $arrProduct['cart_id'], 'SHOP_PRODUCT_TITLE' => str_replace('"', '"', contrexx_raw2xhtml($arrProduct['title'])), 'SHOP_PRODUCT_PRICE' => $arrProduct['price'], 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => $arrProduct['itemprice'], 'SHOP_PRODUCT_ITEMPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_REMOVE_PRODUCT' => $_ARRAYLANG['TXT_SHOP_REMOVE_ITEM']));
//DBG::log("Attributes String: {$arrProduct['options_long']}");
if ($arrProduct['options_long']) {
$objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $arrProduct['options_long']);
}
if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
$objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($arrProduct['weight']), 'TXT_WEIGHT' => $_ARRAYLANG['TXT_TOTAL_WEIGHT']));
}
if (Vat::isEnabled()) {
$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $arrProduct['vat_rate'] ? Vat::format($arrProduct['vat_rate']) : '', 'SHOP_PRODUCT_TAX_AMOUNT' => $arrProduct['vat_amount'] . ' ' . Currency::getActiveCurrencySymbol()));
}
if (intval($arrProduct['minimum_order_quantity']) > 0) {
$objTemplate->setVariable(array('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY' => $arrProduct['minimum_order_quantity']));
} else {
if ($objTemplate->blockExists('orderQuantity')) {
$objTemplate->hideBlock('orderQuantity');
}
if ($objTemplate->blockExists('minimumOrderQuantity')) {
$objTemplate->hideBlock('minimumOrderQuantity');
}
}
$objTemplate->parse('shopCartRow');
}
} else {
$objTemplate->hideBlock('shopCart');
if ($objTemplate->blockExists('shopCartEmpty')) {
$objTemplate->touchBlock('shopCartEmpty');
$objTemplate->parse('shopCartEmpty');
}
if ($_SESSION['shop']['previous_product_ids']) {
$ids = $_SESSION['shop']['previous_product_ids']->toArray();
Shop::view_product_overview($ids);
}
}
$objTemplate->setGlobalVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'SHOP_PRODUCT_TOTALITEM' => self::get_item_count(), 'SHOP_PRODUCT_TOTALPRICE' => Currency::formatPrice(self::get_price()), 'SHOP_PRODUCT_TOTALPRICE_PLUS_VAT' => Currency::formatPrice(self::get_price() + (Vat::isEnabled() && !Vat::isIncluded() ? self::get_vat_amount() : 0)), 'SHOP_PRODUCT_TOTALPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString(self::get_weight()), 'SHOP_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
// Show the Coupon code field only if there is at least one defined
if (Coupon::count_available()) {
//DBG::log("Coupons available");
$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_CODE' => isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : ''));
if ($objTemplate->blockExists('shopCoupon')) {
$objTemplate->parse('shopCoupon');
}
if (self::get_discount_amount()) {
$total_discount_amount = self::get_discount_amount();
//DBG::log("Shop::view_cart(): Total: Amount $total_discount_amount");
$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
}
}
if (Vat::isEnabled()) {
$objTemplate->setVariable(array('TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_TOTAL_TAX_AMOUNT' => self::get_vat_amount() . ' ' . Currency::getActiveCurrencySymbol()));
if (Vat::isIncluded()) {
$objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . ' ' . Currency::getActiveCurrencySymbol()));
}
//.........这里部分代码省略.........
示例5: send_as_pdf
//.........这里部分代码省略.........
$headerForAllPages = $objPdf->openObject();
$objPdf->saveState();
for ($i = 0; $i < $biggerCountTop; ++$i) {
$headerArray[$i] = array('left' => isset($arrHeaderLeft[$i]) ? $arrHeaderLeft[$i] : '', 'right' => isset($arrHeaderRight[$i]) ? $arrHeaderRight[$i] : '');
}
$tempY = $objPdf->ezTable($headerArray, '', '', array('showHeadings' => 0, 'fontSize' => $this->font_size_header, 'shaded' => 0, 'width' => 540, 'showLines' => 0, 'xPos' => 'center', 'xOrientation' => 'center', 'cols' => array('right' => array('justification' => 'right'))));
$tempY -= 5;
if ($this->border) {
$objPdf->setStrokeColor(0, 0, 0);
$objPdf->line(10, $tempY, 585.28, $tempY);
}
$startpointY = $tempY - 5;
$objPdf->restoreState();
$objPdf->closeObject();
$objPdf->addObject($headerForAllPages, 'all');
}
// Footer
$pageNumbersX = $pageNumbersY = $pageNumbersFont = 0;
if ($this->footer) {
$footerForAllPages = $objPdf->openObject();
$objPdf->saveState();
$tempY = $marginBottom - 5;
if ($this->border) {
$objPdf->setStrokeColor(0, 0, 0);
$objPdf->line(10, $tempY, 585.28, $tempY);
}
// length of the longest word
$longestWord = 0;
foreach ($arrFooterRight as $line) {
if ($longestWord < strlen($line)) {
$longestWord = strlen($line);
}
}
for ($i = $biggerCountBottom - 1; $i >= 0; --$i) {
if (empty($arrFooterLeft[$i])) {
$arrFooterLeft[$i] = '';
}
if (empty($arrFooterRight[$i])) {
$arrFooterRight[$i] = '';
}
if ($arrFooterLeft[$i] == '<--PAGENUMBER-->' || $arrFooterLeft[$i] == '[PAGENUMBER]') {
$pageNumbersX = 65;
$pageNumbersY = $tempY - 18 - $i * $this->font_size_footer;
$pageNumbersFont = $this->font_size_list;
} else {
$objPdf->addText(25, $tempY - 18 - $i * $this->font_size_footer, $this->font_size_footer, $arrFooterLeft[$i]);
}
if ($arrFooterRight[$i] == '<--PAGENUMBER-->' || $arrFooterRight[$i] == '[PAGENUMBER]') {
$pageNumbersX = 595.28 - 25;
$pageNumbersY = $tempY - 18 - $i * $this->font_size_footer;
$pageNumbersFont = $this->font_size_list;
} else {
// Properly align right
$width = $objPdf->getTextWidth($this->font_size_footer, $arrFooterRight[$i]);
$objPdf->addText(595.28 - $width - 25, $tempY - 18 - $i * $this->font_size_footer, $this->font_size_footer, $arrFooterRight[$i]);
}
}
$objPdf->restoreState();
$objPdf->closeObject();
$objPdf->addObject($footerForAllPages, 'all');
}
// Page numbers
if (isset($pageNumbersX)) {
$objPdf->ezStartPageNumbers($pageNumbersX, $pageNumbersY, $pageNumbersFont, '', $_ARRAYLANG['TXT_SHOP_PRICELIST_FORMAT_PAGENUMBER'], 1);
}
// Margins
$objPdf->ezSetMargins($marginTop, $marginBottom, 30, 30);
// Product table
if (isset($startpointY)) {
$objPdf->ezSetY($startpointY);
}
$objInit->backendLangId = $this->lang_id;
$_ARRAYLANG = $objInit->loadLanguageData('Shop');
Currency::setActiveCurrencyId($this->currency_id);
$currency_symbol = Currency::getActiveCurrencySymbol();
$category_ids = $this->category_ids();
if ($category_ids == '*') {
$category_ids = null;
}
$count = 1000;
// Be sensible!
// Pattern is "%" because all-empty parameters will result in an
// empty array!
$arrProduct = Products::getByShopParams($count, 0, null, $category_ids, null, '%', null, null, '`category_id` ASC, `name` ASC');
$arrCategoryName = ShopCategories::getNameArray();
$arrOutput = array();
foreach ($arrProduct as $product_id => $objProduct) {
$categoryIds = explode(',', $objProduct->category_id());
$arrCategoryNames = array();
foreach ($categoryIds as $categoryId) {
$arrCategoryNames[] = $arrCategoryName[$categoryId];
}
//$objProduct = new Product();
$arrOutput[$product_id] = array('product_name' => self::decode($objProduct->name()), 'category_name' => self::decode(implode(', ', $arrCategoryNames)), 'product_code' => self::decode($objProduct->code()), 'product_id' => self::decode($objProduct->id()), 'price' => ($objProduct->discount_active() ? "S " . Currency::formatPrice($objProduct->discountprice()) : Currency::formatPrice($objProduct->price())) . ' ' . $currency_symbol);
}
$objPdf->ezTable($arrOutput, array('product_name' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRODUCT_NAME']) . '</b>', 'category_name' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_CATEGORY_NAME']) . '</b>', 'product_code' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRODUCT_CODE']) . '</b>', 'product_id' => '<b>' . self::decode($_ARRAYLANG['TXT_ID']) . '</b>', 'price' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRICE']) . '</b>'), '', array('showHeadings' => 1, 'fontSize' => $this->font_size_list, 'width' => 530, 'innerLineThickness' => 0.5, 'outerLineThickness' => 0.5, 'shaded' => 2, 'shadeCol' => array(hexdec(substr($this->row_color_1, 0, 2)) / 255, hexdec(substr($this->row_color_1, 2, 2)) / 255, hexdec(substr($this->row_color_1, 4, 2)) / 255), 'shadeCol2' => array(hexdec(substr($this->row_color_2, 0, 2)) / 255, hexdec(substr($this->row_color_2, 2, 2)) / 255, hexdec(substr($this->row_color_2, 4, 2)) / 255), 'cols' => array('product_name' => array('width' => 255), 'category_name' => array('width' => 130), 'product_code' => array('width' => 50), 'product_id' => array('width' => 40, 'justification' => 'right'), 'price' => array('width' => 55, 'justification' => 'right'))));
$objPdf->ezStream();
// Never reached
return true;
}
示例6: view_items
//.........这里部分代码省略.........
// Mind the custom price calculation
$objCustomer = Customer::getById($this->customer_id);
if (!$objCustomer) {
\Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_MISSING_CUSTOMER'], $this->customer_id));
$objCustomer = new Customer();
}
$query = "\n SELECT `id`, `product_id`, `product_name`,\n `price`, `quantity`, `vat_rate`, `weight`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items`\n WHERE `order_id`=?";
$objResult = $objDatabase->Execute($query, array($this->id));
if (!$objResult) {
return self::errorHandler();
}
$arrProductOptions = $this->getOptionArray();
$total_vat_amount = 0;
$total_net_price = 0;
// Orders with Attributes cannot currently be edited
// (this would spoil all the options!)
// $have_option = false;
while (!$objResult->EOF) {
$item_id = $objResult->fields['id'];
$name = $objResult->fields['product_name'];
$price = $objResult->fields['price'];
$quantity = $objResult->fields['quantity'];
$vat_rate = $objResult->fields['vat_rate'];
$product_id = $objResult->fields['product_id'];
// Get missing product details
$objProduct = Product::getById($product_id);
if (!$objProduct) {
\Message::warning(sprintf($_ARRAYLANG['TXT_SHOP_PRODUCT_NOT_FOUND'], $product_id));
$objProduct = new Product('', 0, $name, '', $price, 0, 0, 0, $product_id);
}
$code = $objProduct->code();
$distribution = $objProduct->distribution();
if (isset($arrProductOptions[$item_id])) {
if ($edit) {
// Edit options
} else {
//DBG::log("Order::view_items(): Item ID $item_id, Attributes: ".var_export($arrProductOptions[$item_id], true));
// Verify that options are properly shown
foreach ($arrProductOptions[$item_id] as $attribute_id => $attribute) {
//DBG::log("Order::view_items(): Added option, price: $options_price");
foreach ($attribute as $a) {
$name .= '<i><br />- ' . $attribute_id . ': ' . $a['name'] . ' (' . $a['price'] . ')</i>';
$price += $a['price'];
}
}
}
}
// c_sp
$row_net_price = $price * $quantity;
$row_price = $row_net_price;
// VAT added later, if applicable
$total_net_price += $row_net_price;
// Here, the VAT has to be recalculated before setting up the
// fields. If the VAT is excluded, it must be added here.
// Note: the old Order.vat_amount field is no longer valid,
// individual shop_order_items *MUST* have been UPDATEd by the
// time PHP parses this line.
// Also note that this implies that the vat_id and
// country_id can be ignored, as they are considered when the
// order is placed and the VAT is applied to the order
// accordingly.
// Calculate the VAT amount per row, included or excluded
$row_vat_amount = Vat::amount($vat_rate, $row_net_price);
//\DBG::log("$row_vat_amount = Vat::amount($vat_rate, $row_net_price)");
// and add it to the total VAT amount
$total_vat_amount += $row_vat_amount;
if (!Vat::isIncluded()) {
// Add tax to price
$row_price += $row_vat_amount;
}
//else {
// VAT is disabled.
// There shouldn't be any non-zero percentages in the order_items!
// but if there are, there probably has been a change and we *SHOULD*
// still treat them as if VAT had been enabled at the time the order
// was placed!
// That's why the else {} block is commented out.
//}
$weight = '-';
if ($distribution != 'download') {
$weight = $objResult->fields['weight'];
if (intval($weight) > 0) {
$total_weight += $weight * $quantity;
}
}
$itemHasOptions = !empty($arrProductOptions[$item_id]);
$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $product_id, 'SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_QUANTITY' => $quantity, 'SHOP_PRODUCT_NAME' => $name, 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price), 'SHOP_PRODUCT_SUM' => Currency::formatPrice($row_net_price), 'SHOP_P_ID' => $edit ? $item_id : $objResult->fields['product_id'], 'SHOP_PRODUCT_CODE' => $code, 'SHOP_PRODUCT_TAX_RATE' => $edit ? $vat_rate : Vat::format($vat_rate), 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($row_vat_amount), 'SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($weight), 'SHOP_ACCOUNT_VALIDITY' => \FWUser::getValidityString($weight)));
// Get a product menu for each Product if $edit-ing.
// Preselect the current Product ID.
if ($edit) {
if ($itemHasOptions && $objTemplate->blockExists('order_item_product_options_tooltip')) {
$objTemplate->touchBlock('order_item_product_options_tooltip');
}
$objTemplate->setVariable('SHOP_PRODUCT_IDS_MENU', Products::getMenuoptions($product_id, null, +$_ARRAYLANG['TXT_SHOP_PRODUCT_MENU_FORMAT'], false));
}
$objTemplate->parse('order_item');
$objResult->MoveNext();
}
return $total_net_price;
}
示例7: view_product_overview
/**
* Show Products
*/
function view_product_overview()
{
global $_ARRAYLANG;
if (isset($_POST['bsubmit'])) {
$this->update_products();
}
if (isset($_POST['multi_action'])) {
if ($_POST['multi_action'] == 'activate') {
Products::set_active($_POST['selectedProductId'], true);
} elseif ($_POST['multi_action'] == 'deactivate') {
Products::set_active($_POST['selectedProductId'], false);
}
}
self::$objTemplate->addBlockfile('SHOP_PRODUCTS_FILE', 'shop_products_block', 'module_shop_product_catalog.html');
self::$objTemplate->setGlobalVariable($_ARRAYLANG);
$category_id = empty($_REQUEST['category_id']) ? null : intval($_REQUEST['category_id']);
//DBG::log("Requested Category ID: $category_id");
$manufacturer_id = empty($_REQUEST['manufacturer_id']) ? null : intval($_REQUEST['manufacturer_id']);
$flagSpecialoffer = isset($_REQUEST['specialoffer']);
$searchTerm = empty($_REQUEST['searchterm']) ? null : trim(contrexx_input2raw($_REQUEST['searchterm']));
$url = \Html::getRelativeUri();
// TODO: Strip URL parameters: Which?
// \Html::stripUriParam($url, '');
$arrSorting = array('`product`.`id`' => $_ARRAYLANG['TXT_SHOP_ID'], '`product`.`active`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_ACTIVE'], '`product`.`ord`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_ORDER'], 'name' => $_ARRAYLANG['TXT_SHOP_PRODUCT_NAME'], 'code' => $_ARRAYLANG['TXT_SHOP_PRODUCT_CODE'], '`product`.`discountprice`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_DISCOUNTPRICE'], '`product`.`normalprice`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_NORMALPRICE'], '`product`.`resellerprice`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_RESELLERPRICE'], '`product`.`distribution`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_DISTRIBUTION'], '`product`.`stock`' => $_ARRAYLANG['TXT_SHOP_PRODUCT_STOCK']);
$objSorting = new \Sorting($url, $arrSorting, false, 'order_shop_product');
$limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_products_per_page_backend', 'Shop');
$tries = 2;
while ($tries--) {
// have to set $count again because it will be set to 0 in Products::getByShopParams
$count = $limit;
// Mind that $count is handed over by reference.
$arrProducts = Products::getByShopParams($count, \Paging::getPosition(), 0, $category_id, $manufacturer_id, $searchTerm, $flagSpecialoffer, false, $objSorting->getOrder(), null, true);
if (count($arrProducts) > 0 || \Paging::getPosition() == 0) {
break;
}
\Paging::reset();
}
self::$objTemplate->setVariable(array('SHOP_CATEGORY_MENU' => \Html::getSelect('category_id', array(0 => $_ARRAYLANG['TXT_ALL_PRODUCT_GROUPS']) + ShopCategories::getNameArray(), $category_id), 'SHOP_SEARCH_TERM' => $searchTerm, 'SHOP_PRODUCT_TOTAL' => $count));
if (empty($arrProducts)) {
self::$objTemplate->touchBlock('no_product');
return true;
}
self::$objTemplate->setVariable(array('SHOP_PRODUCT_PAGING' => \Paging::get($url, '<b>' . $_ARRAYLANG['TXT_PRODUCTS'] . '</b>', $count, $limit, true), 'SHOP_HEADING_PRODUCT_ID' => $objSorting->getHeaderForField('`product`.`id`'), 'SHOP_HEADING_PRODUCT_ACTIVE' => $objSorting->getHeaderForField('`product`.`active`'), 'SHOP_HEADING_PRODUCT_ORD' => $objSorting->getHeaderForField('`product`.`ord`'), 'SHOP_HEADING_PRODUCT_NAME' => $objSorting->getHeaderForField('name'), 'SHOP_HEADING_PRODUCT_CODE' => $objSorting->getHeaderForField('code'), 'SHOP_HEADING_PRODUCT_DISCOUNTPRICE' => $objSorting->getHeaderForField('`product`.`discountprice`'), 'SHOP_HEADING_PRODUCT_NORMALPRICE' => $objSorting->getHeaderForField('`product`.`normalprice`'), 'SHOP_HEADING_PRODUCT_RESELLERPRICE' => $objSorting->getHeaderForField('`product`.`resellerprice`'), 'SHOP_HEADING_PRODUCT_DISTRIBUTION' => $objSorting->getHeaderForField('`product`.`distribution`'), 'SHOP_HEADING_PRODUCT_STOCK' => $objSorting->getHeaderForField('`product`.`stock`')));
$arrLanguages = \FWLanguage::getActiveFrontendLanguages();
// Intended to show an edit link for all active frontend languages.
// However, the design doesn't like it. Limit to the current one.
$arrLanguages = array(FRONTEND_LANG_ID => $arrLanguages[FRONTEND_LANG_ID]);
$i = 0;
foreach ($arrProducts as $objProduct) {
$productStatus = '';
$productStatusValue = '';
$productStatusPicture = 'status_red.gif';
if ($objProduct->active()) {
$productStatus = \Html::ATTRIBUTE_CHECKED;
$productStatusValue = 1;
$productStatusPicture = 'status_green.gif';
}
$discount_active = '';
$specialOfferValue = '';
if ($objProduct->discount_active()) {
$discount_active = \Html::ATTRIBUTE_CHECKED;
$specialOfferValue = 1;
}
self::$objTemplate->setGlobalVariable(array('SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $objProduct->id(), 'SHOP_PRODUCT_CODE' => $objProduct->code(), 'SHOP_PRODUCT_NAME' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_PRICE1' => Currency::formatPrice($objProduct->price()), 'SHOP_PRODUCT_PRICE2' => Currency::formatPrice($objProduct->resellerprice()), 'SHOP_PRODUCT_DISCOUNT' => Currency::formatPrice($objProduct->discountprice()), 'SHOP_PRODUCT_SPECIAL_OFFER' => $discount_active, 'SHOP_SPECIAL_OFFER_VALUE_OLD' => $specialOfferValue, 'SHOP_PRODUCT_VAT_MENU' => Vat::getShortMenuString($objProduct->vat_id(), 'taxId[' . $objProduct->id() . ']'), 'SHOP_PRODUCT_VAT_ID' => $objProduct->vat_id() ? $objProduct->vat_id() : 'NULL', 'SHOP_PRODUCT_DISTRIBUTION' => $objProduct->distribution(), 'SHOP_PRODUCT_STOCK' => $objProduct->stock(), 'SHOP_PRODUCT_SHORT_DESC' => $objProduct->short(), 'SHOP_PRODUCT_STATUS' => $productStatus, 'SHOP_PRODUCT_STATUS_PICTURE' => $productStatusPicture, 'SHOP_ACTIVE_VALUE_OLD' => $productStatusValue, 'SHOP_SORT_ORDER' => $objProduct->ord(), 'SHOP_DISTRIBUTION' => $_ARRAYLANG['TXT_DISTRIBUTION_' . strtoupper($objProduct->distribution())], 'SHOP_SHOW_PRODUCT_ON_START_PAGE_CHECKED' => $objProduct->shown_on_startpage() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_SHOW_PRODUCT_ON_START_PAGE_OLD' => $objProduct->shown_on_startpage() ? '1' : '', 'SHOP_PRODUCT_NAME' => contrexx_raw2xhtml($objProduct->name())));
// All languages active
foreach ($arrLanguages as $lang_id => $arrLanguage) {
self::$objTemplate->setVariable(array('SHOP_PRODUCT_LANGUAGE_ID' => $lang_id, 'SHOP_PRODUCT_LANGUAGE_EDIT' => sprintf($_ARRAYLANG['TXT_SHOP_PRODUCT_LANGUAGE_EDIT'], $lang_id, $arrLanguage['lang'], $arrLanguage['name'])));
self::$objTemplate->parse('product_language');
}
self::$objTemplate->touchBlock('productRow');
self::$objTemplate->parse('productRow');
}
return true;
}
示例8: formatPrice
function formatPrice($price, $selected_currency = null)
{
if (parseFloat($price) > 0) {
global $db, $home_dir;
require_once $home_dir . 'models/currency.m.php';
return Currency::formatPrice($db, $price, $selected_currency);
} else {
return t('Free');
}
}