本文整理汇总了PHP中CCurrency::checkCurrencyID方法的典型用法代码示例。如果您正苦于以下问题:PHP CCurrency::checkCurrencyID方法的具体用法?PHP CCurrency::checkCurrencyID怎么用?PHP CCurrency::checkCurrencyID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCurrency
的用法示例。
在下文中一共展示了CCurrency::checkCurrencyID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: require_once
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/currency/prolog.php");
$CURRENCY_RIGHT = $APPLICATION->GetGroupRight("currency");
if ($CURRENCY_RIGHT=="D") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
CModule::IncludeModule('currency');
IncludeModuleLangFile(__FILE__);
$sTableID = "t_currencies";
$oSort = new CAdminSorting($sTableID, "sort", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
if ($lAdmin->EditAction() && $CURRENCY_RIGHT=="W")
{
foreach($FIELDS as $ID => $arFields)
{
$ID = (string)$ID;
$ID = CCurrency::checkCurrencyID($ID);
if ($ID === false)
continue;
if (!$lAdmin->IsUpdated($ID))
continue;
if (!CCurrency::Update($ID, $arFields))
{
if ($ex = $APPLICATION->GetException())
{
$lAdmin->AddUpdateError(GetMessage("CURRENCY_SAVE_ERR", array("#ID#" => $ID, "#ERROR_TEXT#" => $ex->GetString())), $ID);
}
else
{
$lAdmin->AddUpdateError(GetMessage("CURRENCY_SAVE_ERR2", array("#ID#"=>$ID)), $ID);
示例2: calculateDiscSave
protected static function calculateDiscSave($basePrice, $price, $currency, &$discsaveList, &$resultDiscount)
{
$basePrice = (double) $basePrice;
$price = (double) $price;
$currency = CCurrency::checkCurrencyID($currency);
if ($basePrice <= 0 || $price <= 0 || $currency === false) {
return false;
}
$currentPrice = $price;
$minPrice = false;
$minIndex = -1;
$apply = false;
foreach ($discsaveList as $discountIndex => $oneDiscount) {
$calculatePrice = false;
switch ($oneDiscount['VALUE_TYPE']) {
case CCatalogDiscountSave::TYPE_PERCENT:
$discountValue = (self::$getPercentFromBasePrice ? $basePrice : $currentPrice) * $oneDiscount['VALUE'] / 100;
$needErase = $currentPrice < $discountValue;
if (!$needErase) {
$calculatePrice = $currentPrice - $discountValue;
}
unset($discountValue);
break;
case CCatalogDiscountSave::TYPE_FIX:
$needErase = $oneDiscount['DISCOUNT_CONVERT'] > $currentPrice;
if (!$needErase) {
$calculatePrice = $currentPrice - $oneDiscount['DISCOUNT_CONVERT'];
}
break;
default:
$needErase = true;
break;
}
if (!$needErase) {
$apply = $minPrice === false || $minPrice > $calculatePrice;
if ($apply) {
$minPrice = $calculatePrice;
$minIndex = $discountIndex;
}
}
}
if ($minPrice !== false && isset($discsaveList[$minIndex])) {
$currentPrice = $minPrice;
$resultDiscount[] = $discsaveList[$minIndex];
}
return $currentPrice;
}
示例3: CountPriceWithDiscount
/**
* <p>Метод применяет к цене <i>price</i> в валюте <i>currency</i> цепочку скидок из массива <i>arDiscounts</i>. Метод динамичный.</p> <p></p> <div class="note"> <b>Примечание:</b> до версии модуля <b>12.0</b> метод применял к цене <i>price</i> в валюте <i>currency</i> наибольшую скидку из массива <i>arDiscounts</i>.</div>
*
*
* @param double $price Цена.</b
*
* @param string $currency Валюта цены.
*
* @param array $arDiscounts массив ассоциативных массивов скидок. Имеет вид: <pre class="syntax">array(
* array( "VALUE_TYPE" => "тип скидки (P - в процентах, F - фиксированная сумма)",
* "VALUE" => "величина скидки", "CURRENCY" => "валюта", "MAX_DISCOUNT" =>
* "максимальный размер скидки" ), array( "VALUE_TYPE" => "тип скидки (P - в
* процентах, F - фиксированная сумма)", "VALUE" => "величина скидки",
* "CURRENCY" => "валюта", "MAX_DISCOUNT" => "максимальный размер скидки" ), * * * )
* </pre>
*
* @return array <p>Метод возвращает цену, получившуюся после применения цепочки
* скидок.</p> <p></p><div class="note"> <b>Примечание:</b> до версии модуля <b>12.0.0</b>
* метод возвращал наименьшую цену, которую можно было получить с
* помощью наибольшей скидки.</div> <a name="examples"></a>
*
* <h4>Example</h4>
* <pre>
* <?
* // Для товара с кодом $ID выведем различные цены (по типу и количеству), по
* // которым данный товар может быть куплен текущим пользователем
*
* $dbPrice = CPrice::GetList(
* array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC", "SORT" => "ASC"),
* array("PRODUCT_ID" => $ID),
* false,
* false,
* array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO")
* );
* while ($arPrice = $dbPrice->Fetch())
* {
* $arDiscounts = CCatalogDiscount::GetDiscountByPrice(
* $arPrice["ID"],
* $USER->GetUserGroupArray(),
* "N",
* SITE_ID
* );
* $discountPrice = CCatalogProduct::CountPriceWithDiscount(
* $arPrice["PRICE"],
* $arPrice["CURRENCY"],
* $arDiscounts
* );
* $arPrice["DISCOUNT_PRICE"] = $discountPrice;
*
* echo "<pre>";
* print_r($arPrice);
* echo "</pre>";
* }
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogproduct/ccatalogproduct__countpricewithdiscount.9c16046d.php
* @author Bitrix
*/
public static function CountPriceWithDiscount($price, $currency, $arDiscounts)
{
static $eventOnGetExists = null;
static $eventOnResultExists = null;
if ($eventOnGetExists === true || $eventOnGetExists === null) {
foreach (GetModuleEvents('catalog', 'OnCountPriceWithDiscount', true) as $arEvent) {
$eventOnGetExists = true;
$mxResult = ExecuteModuleEventEx($arEvent, array($price, $currency, $arDiscounts));
if ($mxResult !== true) {
return $mxResult;
}
}
if ($eventOnGetExists === null) {
$eventOnGetExists = false;
}
}
$currency = CCurrency::checkCurrencyID($currency);
if ($currency === false) {
return false;
}
$price = (double) $price;
if ($price <= 0) {
return $price;
}
if (empty($arDiscounts) || !is_array($arDiscounts)) {
return $price;
}
$result = CCatalogDiscount::applyDiscountList($price, $currency, $arDiscounts);
if ($result === false) {
return false;
}
$currentMinPrice = $result['PRICE'];
if ($eventOnResultExists === true || $eventOnResultExists === null) {
foreach (GetModuleEvents('catalog', 'OnCountPriceWithDiscountResult', true) as $arEvent) {
$eventOnResultExists = true;
if (ExecuteModuleEventEx($arEvent, array(&$currentMinPrice)) === false) {
return false;
}
}
//.........这里部分代码省略.........
示例4: OrderProduct
/**
* @param array $arParams
* @return array|false
*/
public static function OrderProduct($arParams)
{
$arParams['RENEWAL'] = (isset($arParams['RENEWAL']) && $arParams['RENEWAL'] == 'Y' ? 'Y' : 'N');
$arParams['CHECK_QUANTITY'] = (isset($arParams['CHECK_QUANTITY']) && $arParams['CHECK_QUANTITY'] == 'N' ? 'N' : 'Y');
$arParams['CHECK_DISCOUNT'] = (isset($arParams['CHECK_DISCOUNT']) && $arParams['CHECK_DISCOUNT'] == 'N' ? 'N' : 'Y');
$arParams['USER_ID'] = (isset($arParams['USER_ID']) ? (int)$arParams['USER_ID'] : 0);
if ($arParams['USER_ID'] < 0)
$arParams['USER_ID'] = 0;
$arParams['SITE_ID'] = (isset($arParams['SITE_ID']) ? $arParams['SITE_ID'] : false);
$strSiteID = $arParams['SITE_ID'];
$arParams['BASKET_ID'] = (string)(isset($arParams['BASKET_ID']) ? $arParams['BASKET_ID'] : '0');
if (isset($arParams['CURRENCY']))
$arParams['CURRENCY'] = CCurrency::checkCurrencyID($arParams['CURRENCY']);
if ($arParams['CURRENCY'] === false)
$arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID);
global $USER;
$productID = (int)$arParams['PRODUCT_ID'];
$quantity = (float)$arParams['QUANTITY'];
$renewal = $arParams['RENEWAL'];
$intUserID = (int)$arParams['USER_ID'];
$arResult = array();
static $arUserCache = array();
if (0 < $intUserID)
{
if (!isset($arUserCache[$intUserID]))
{
$by = 'ID';
$order = 'DESC';
$rsUsers = CUser::GetList($by, $order, array("ID_EQUAL_EXACT"=>$intUserID),array('FIELDS' => array('ID')));
if ($arUser = $rsUsers->Fetch())
{
$arUser['ID'] = intval($arUser['ID']);
$arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
}
else
{
$intUserID = 0;
return $arResult;
}
}
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSION" => "N",
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
);
if(!($arProduct = $dbIBlockElement->GetNext()))
return $arResult;
if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE"))
{
$arUserRights = CIBlockElementRights::GetUserOperations($productID,$intUserID);
if (empty($arUserRights))
{
return $arResult;
}
elseif (!is_array($arUserRights) || !array_key_exists('element_read',$arUserRights))
{
return $arResult;
}
}
else
{
if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID))
{
return $arResult;
}
}
}
else
{
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSIONS" => "Y",
"MIN_PERMISSION" => "R",
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
//.........这里部分代码省略.........
示例5: isExistCurrencyLanguage
public static function isExistCurrencyLanguage($currency, $language)
{
global $DB;
$currency = CCurrency::checkCurrencyID($currency);
$language = self::checkLanguage($language);
if ($currency === false || $language === false) {
return false;
}
$query = "select LID from b_catalog_currency_lang where CURRENCY = '" . $DB->ForSql($currency) . "' and LID = '" . $DB->ForSql($language) . "'";
$searchIterator = $DB->Query($query, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
if ($result = $searchIterator->Fetch()) {
return true;
}
return false;
}