本文整理汇总了PHP中CCurrencyRates::ConvertCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP CCurrencyRates::ConvertCurrency方法的具体用法?PHP CCurrencyRates::ConvertCurrency怎么用?PHP CCurrencyRates::ConvertCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCurrencyRates
的用法示例。
在下文中一共展示了CCurrencyRates::ConvertCurrency方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PrepareCurrency4Where
public static function PrepareCurrency4Where($val, $key, $operation, $negative, $field, &$arField, &$arFilter)
{
$val = DoubleVal($val);
$baseSiteCurrency = "";
if (isset($arFilter["LID"]) && strlen($arFilter["LID"]) > 0)
$baseSiteCurrency = CSaleLang::GetLangCurrency($arFilter["LID"]);
elseif (isset($arFilter["CURRENCY"]) && strlen($arFilter["CURRENCY"]) > 0)
$baseSiteCurrency = $arFilter["CURRENCY"];
if (strlen($baseSiteCurrency) <= 0)
return False;
$strSqlSearch = "";
$dbCurrency = CCurrency::GetList(($by = "sort"), ($order = "asc"));
while ($arCurrency = $dbCurrency->Fetch())
{
$val1 = roundEx(CCurrencyRates::ConvertCurrency($val, $baseSiteCurrency, $arCurrency["CURRENCY"]), SALE_VALUE_PRECISION);
if (strlen($strSqlSearch) > 0)
$strSqlSearch .= " OR ";
$strSqlSearch .= "(D.ORDER_CURRENCY = '".$arCurrency["CURRENCY"]."' AND ";
if ($negative == "Y")
$strSqlSearch .= "NOT";
$strSqlSearch .= "(".$field." ".$operation." ".$val1." OR ".$field." IS NULL OR ".$field." = 0)";
$strSqlSearch .= ")";
}
return "(".$strSqlSearch.")";
}
示例2: DoProcessOrderDelivery
static function DoProcessOrderDelivery(&$arOrder, $arOptions, &$arErrors)
{
if ((!array_key_exists("TAX_LOCATION", $arOrder) || intval($arOrder["TAX_LOCATION"]) <= 0) && !$arOrder["USE_VAT"]) {
return;
}
if (!array_key_exists("COUNT_DELIVERY_TAX", $arOptions)) {
$arOptions["COUNT_DELIVERY_TAX"] = COption::GetOptionString("sale", "COUNT_DELIVERY_TAX", "N");
}
if (doubleval($arOrder["DELIVERY_PRICE"]) <= 0 || $arOptions["COUNT_DELIVERY_TAX"] != "Y") {
return;
}
if (!$arOrder["USE_VAT"]) {
if (!array_key_exists("TAX_EXEMPT", $arOrder)) {
$arUserGroups = CUser::GetUserGroup($arOrder["USER_ID"]);
$dbTaxExemptList = CSaleTax::GetExemptList(array("GROUP_ID" => $arUserGroups));
while ($TaxExemptList = $dbTaxExemptList->Fetch()) {
if (!in_array(intval($TaxExemptList["TAX_ID"]), $arOrder["TAX_EXEMPT"])) {
$arOrder["TAX_EXEMPT"][] = intval($TaxExemptList["TAX_ID"]);
}
}
}
if (!array_key_exists("TAX_LIST", $arOrder)) {
$arOrder["TAX_LIST"] = array();
$dbTaxRate = CSaleTaxRate::GetList(array("APPLY_ORDER" => "ASC"), array("LID" => $arOrder["SITE_ID"], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"], "ACTIVE" => "Y", "LOCATION" => $arOrder["TAX_LOCATION"]));
while ($arTaxRate = $dbTaxRate->GetNext()) {
if (!in_array(intval($arTaxRate["TAX_ID"]), $arOrder["TAX_EXEMPT"])) {
if ($arTaxRate["IS_PERCENT"] != "Y") {
$arTaxRate["VALUE"] = RoundEx(CCurrencyRates::ConvertCurrency($arTaxRate["VALUE"], $arTaxRate["CURRENCY"], $arOrder["CURRENCY"]), SALE_VALUE_PRECISION);
$arTaxRate["CURRENCY"] = $arOrder["CURRENCY"];
}
$arOrder["TAX_LIST"][] = $arTaxRate;
}
}
}
if (count($arOrder["TAX_LIST"]) > 0) {
CSaleOrderTax::CountTaxes($arOrder["DELIVERY_PRICE"], $arOrder["TAX_LIST"], $arOrder["CURRENCY"]);
foreach ($arOrder["TAX_LIST"] as &$arTax) {
$arTax["VALUE_MONEY"] += roundEx($arTax["TAX_VAL"], SALE_VALUE_PRECISION);
}
unset($arTax);
$arOrder["TAX_PRICE"] = 0;
foreach ($arOrder["TAX_LIST"] as $arTax) {
if ($arTax["IS_IN_PRICE"] != "Y") {
$arOrder["TAX_PRICE"] += roundEx($arTax["VALUE_MONEY"], SALE_VALUE_PRECISION);
}
}
}
} else {
$deliveryVat = roundEx($arOrder["DELIVERY_PRICE"] * $arOrder["VAT_RATE"] / (1 + $arOrder["VAT_RATE"]), 2);
$arOrder["VAT_SUM"] += $deliveryVat;
$arOrder["VAT_DELIVERY"] += $deliveryVat;
//if (!array_key_exists("TAX_LIST", $arOrder))
//{
$arOrder["TAX_LIST"][0] = array("NAME" => GetMessage("SOA_VAT"), "IS_PERCENT" => "Y", "VALUE" => $arOrder["VAT_RATE"] * 100, "VALUE_FORMATED" => "(" . $arOrder["VAT_RATE"] * 100 . "%, " . GetMessage("SOA_VAT_INCLUDED") . ")", "VALUE_MONEY" => $arOrder["VAT_SUM"], "VALUE_MONEY_FORMATED" => SaleFormatCurrency($arOrder["VAT_SUM"], $arOrder["CURRENCY"]), "APPLY_ORDER" => 100, "IS_IN_PRICE" => "Y", "CODE" => "VAT");
//}
}
}
示例3: OnSalePayOrderHandler
/**
* Обработчик события подтверждения оплаты товара
*/
function OnSalePayOrderHandler($id, $val)
{
$currentUserId = $GLOBALS['USER']->GetID();
//Идентификатор текущего пользователя, по идее администратор
$idRatingGroup = 5;
//группа акции
$curTo = "UAH";
//тип гривневой цены
$arOrder = CSaleOrder::GetByID($id);
//информация о заказе
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["SUM_PAID"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//стоимость заказа
$userId = intval($arOrder["USER_ID"]);
//пользователь, который оплатил заказ
$arUserData = CUser::GetByID($userId)->Fetch();
//Информация о пользователе
$userGroups = CUser::GetUserGroup($userId);
//ИД групп, к которым принадлежит пользователь
//Если пользователя нет в акционной группе, и он совершил заказ более чем на 900 грн, то добавить его в группу
if (!in_array($idRatingGroup, $userGroups)) {
if ($price >= 900 && $price <= 4000 && $val === 'Y') {
$userGroups[] = $idRatingGroup;
CUser::SetUserGroup($userId, $userGroups);
}
}
$points = $price * 5;
$payedUser = new CUser();
//Если оплата подтверждается, то добавить баллы
if ($val === 'Y' && in_array($idRatingGroup, $userGroups)) {
$points = intval($arUserData['UF_ACTION_POINTS']) + $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points, "UF_DATE_LAST_BUY" => $arOrder["DATE_UPDATE_FORMAT"]));
} else {
if ($val === 'N') {
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["PRICE"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//вычитаем полную стоимость
$points = $price * 5;
if ($arUserData['UF_ACTION_POINTS'] >= $points) {
$points = intval($arUserData['UF_ACTION_POINTS']) - $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points));
//Если очков стало меньше 4500, то исключаем пользователя из группы участников
if (in_array($idRatingGroup, $userGroups) && $points < 4500) {
$indexGroup = array_search($idRatingGroup, $userGroups);
if (isset($userGroups[$indexGroup])) {
unset($userGroups[$indexGroup]);
CUser::SetUserGroup($userId, $userGroups);
}
}
}
}
}
unset($payedUser);
}
示例4: convertToBaseCurrency
public static function convertToBaseCurrency($value, $currency)
{
static $module, $baseCurrency;
if (!$module) {
$module = Loader::includeModule('currency');
$baseCurrency = Config::getBaseCurrency();
}
if ($module && $currency != $baseCurrency) {
$value = \CCurrencyRates::ConvertCurrency($value, $currency, $baseCurrency);
}
return $value;
}
示例5: DoProcessOrder
static function DoProcessOrder(&$arOrder, $deliveryId, &$arErrors)
{
if (!array_key_exists("DELIVERY_LOCATION", $arOrder) || intval($arOrder["DELIVERY_LOCATION"]) <= 0)
return;
if (strlen($deliveryId) > 0 && strpos($deliveryId, ":") !== false)
{
$arOrder["DELIVERY_ID"] = $deliveryId;
$delivery = explode(":", $deliveryId);
$arOrderTmpDel = array(
"PRICE" => $arOrder["ORDER_PRICE"] + $arOrder["TAX_PRICE"] - $arOrder["DISCOUNT_PRICE"],
"WEIGHT" => $arOrder["ORDER_WEIGHT"],
"LOCATION_FROM" => COption::GetOptionString('sale', 'location', '2961', $arOrder["SITE_ID"]),
"LOCATION_TO" => $arOrder["DELIVERY_LOCATION"],
"LOCATION_ZIP" => $arOrder["DELIVERY_LOCATION_ZIP"],
"ITEMS" => $arOrder["BASKET_ITEMS"]
);
$arDeliveryPrice = CSaleDeliveryHandler::CalculateFull($delivery[0], $delivery[1], $arOrderTmpDel, $arOrder["CURRENCY"],$arOrder["LID"]);
if ($arDeliveryPrice["RESULT"] == "ERROR")
$arErrors[] = array("CODE" => "CALCULATE", "TEXT" => $arDeliveryPrice["TEXT"]);
else
$arOrder["DELIVERY_PRICE"] = roundEx($arDeliveryPrice["VALUE"], SALE_VALUE_PRECISION);
}
elseif (intval($deliveryId) > 0)
{
if ($arDelivery = CSaleDelivery::GetByID($deliveryId))
{
$arOrder["DELIVERY_ID"] = $deliveryId;
$arOrder["DELIVERY_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $arOrder["CURRENCY"]), SALE_VALUE_PRECISION);
}
else
{
$arErrors[] = array("CODE" => "CALCULATE", "TEXT" => GetMessage('SKGD_DELIVERY_NOT_FOUND'));
}
}
}
示例6: foreach
$arItem['JS_OFFERS'] = $arMatrix;
$arItem['OFFERS_SELECTED'] = $intSelected;
$arItem['OFFERS_PROPS_DISPLAY'] = $boolSKUDisplayProperties;
} else {
$arMinPrice = false;
$dblMinPrice = 0;
$strMinCurrency = $boolConvert ? $arResult['CONVERT_CURRENCY']['CURRENCY_ID'] : $strBaseCurrency;
foreach ($arItem['OFFERS'] as $keyOffer => $arOffer) {
if (!$arOffer['CAN_BUY']) {
continue;
}
if (empty($arMinPrice)) {
$dblMinPrice = $boolConvert || $arOffer['MIN_PRICE']['CURRENCY'] == $strMinCurrency ? $arOffer['MIN_PRICE']['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arOffer['MIN_PRICE']['DISCOUNT_VALUE'], $arOffer['MIN_PRICE']['CURRENCY'], $strMinCurrency);
$arMinPrice = $arOffer['MIN_PRICE'];
} else {
$dblComparePrice = $boolConvert || $arOffer['MIN_PRICE']['CURRENCY'] == $strMinCurrency ? $arOffer['MIN_PRICE']['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arOffer['MIN_PRICE']['DISCOUNT_VALUE'], $arOffer['MIN_PRICE']['CURRENCY'], $strMinCurrency);
if ($dblMinPrice > $dblComparePrice) {
$dblMinPrice = $dblComparePrice;
$arMinPrice = $arOffer['MIN_PRICE'];
}
}
}
$arItem['MIN_PRICE'] = $arMinPrice;
}
}
if (empty($arItem['PREVIEW_PICTURE'])) {
$arItem['PREVIEW_PICTURE'] = $arItem['DETAIL_PICTURE'];
}
if ('' != $arParams['ADD_PICT_PROP'] && isset($arItem['PROPERTIES'][$arParams['ADD_PICT_PROP']])) {
if ('F' == $arItem['PROPERTIES'][$arParams['ADD_PICT_PROP']]['PROPERTY_TYPE']) {
$arPict = false;
示例7: getPrices
protected function getPrices($productId, $siteId)
{
$minPrice = 0;
$minPriceRUR = 0;
$minPriceGroup = 0;
$minPriceCurrency = "";
$baseCurrency = \CCurrency::GetBaseCurrency();
$RUR = $this->getRub();
if ($this->xmlData['PRICE'] > 0) {
$rsPrices = \CPrice::GetListEx(array(), array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $this->xmlData['PRICE'], 'CAN_BUY' => 'Y', 'GROUP_GROUP_ID' => array(2), '+<=QUANTITY_FROM' => 1, '+>=QUANTITY_TO' => 1));
if ($arPrice = $rsPrices->Fetch()) {
if ($arOptimalPrice = \CCatalogProduct::GetOptimalPrice($productId, 1, array(2), 'N', array($arPrice), $siteId)) {
$minPrice = $arOptimalPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $baseCurrency;
$minPriceRUR = \CCurrencyRates::ConvertCurrency($minPrice, $baseCurrency, $RUR);
$minPriceGroup = $arOptimalPrice['PRICE']['CATALOG_GROUP_ID'];
}
}
} else {
if ($arPrice = \CCatalogProduct::GetOptimalPrice($productId, 1, array(2), 'N', array(), $siteId)) {
$minPrice = $arPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $baseCurrency;
$minPriceRUR = \CCurrencyRates::ConvertCurrency($minPrice, $baseCurrency, $RUR);
$minPriceGroup = $arPrice['PRICE']['CATALOG_GROUP_ID'];
}
}
$result = array("MIN" => $minPrice, "MIN_RUB" => $minPriceRUR, "MIN_GROUP" => $minPriceGroup, "MIN_CURRENCY" => $minPriceCurrency);
return $result;
}
示例8: __ConvertOldFormat
//.........这里部分代码省略.........
$boolResult = false;
$arMsg[] = array('id' => 'ID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_ABSENT'));
}
}
}
}
if ('ADD' == $strAction || $boolUpdate) {
if (!array_key_exists('LID', $arFields)) {
$boolResult = false;
$arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_SITE_ID_ABSENT'));
} else {
$arFields['LID'] = strval($arFields['LID']);
if ('' == $arFields['LID']) {
$boolResult = false;
$arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_SITE_ID_ABSENT'));
} else {
$rsSites = CSite::GetByID($arFields["LID"]);
if (!($arSite = $rsSites->Fetch())) {
$boolResult = false;
$arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('SKGD_NO_SITE', array('#ID#' => $arFields['LID'])));
} else {
$strSiteCurrency = CSaleLang::GetLangCurrency($arFields['LID']);
}
}
}
if (!array_key_exists('CURRENCY', $arFields)) {
$boolResult = false;
$arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_CURRENCY_ABSENT'));
} else {
$arFields['CURRENCY'] = strval($arFields['CURRENCY']);
if ('' == $arFields['CURRENCY']) {
$boolResult = false;
$arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_CURRENCY_ABSENT'));
} else {
if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
$boolResult = false;
$arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('SKGD_NO_CURRENCY', array('#ID#' => $arFields['CURRENCY'])));
}
}
}
if (!array_key_exists("DISCOUNT_TYPE", $arFields)) {
$boolResult = false;
$arMsg[] = array('id' => 'DISCOUNT_TYPE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_TYPE_ABSENT'));
} else {
$arFields["DISCOUNT_TYPE"] = strval($arFields["DISCOUNT_TYPE"]);
if (CSaleDiscount::OLD_DSC_TYPE_PERCENT != $arFields["DISCOUNT_TYPE"] && CSaleDiscount::OLD_DSC_TYPE_FIX != $arFields["DISCOUNT_TYPE"]) {
$boolResult = false;
$arMsg[] = array('id' => 'DISCOUNT_TYPE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_TYPE_BAD'));
}
}
if (!array_key_exists('DISCOUNT_VALUE', $arFields)) {
$boolResult = false;
$arMsg[] = array('id' => 'DISCOUNT_VALUE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_VALUE_ABSENT'));
} else {
$arFields['DISCOUNT_VALUE'] = (double) str_replace(',', '.', $arFields['DISCOUNT_VALUE']);
if (0 >= $arFields['DISCOUNT_VALUE']) {
$boolResult = false;
$arMsg[] = array('id' => 'DISCOUNT_VALUE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_VALUE_BAD'));
}
}
if ($boolResult) {
$arConditions = array('CLASS_ID' => 'CondGroup', 'DATA' => array('All' => 'AND', 'True' => 'True'), 'CHILDREN' => array());
$arActions = array('CLASS_ID' => 'CondGroup', 'DATA' => array('All' => 'AND', 'True' => 'True'), 'CHILDREN' => array());
$boolCurrency = $arFields['CURRENCY'] == $strSiteCurrency;
if (array_key_exists('PRICE_FROM', $arFields)) {
$arFields["PRICE_FROM"] = str_replace(",", ".", strval($arFields["PRICE_FROM"]));
$arFields["PRICE_FROM"] = doubleval($arFields["PRICE_FROM"]);
if (0 < $arFields["PRICE_FROM"]) {
$dblValue = roundEx($boolCurrency ? $arFields['PRICE_FROM'] : CCurrencyRates::ConvertCurrency($arFields['PRICE_FROM'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
$arConditions['CHILDREN'][] = array('CLASS_ID' => 'CondBsktAmtGroup', 'DATA' => array('logic' => 'EqGr', 'Value' => (string) $dblValue, 'All' => 'AND'), 'CHILDREN' => array());
$arFields["PRICE_FROM"] = $dblValue;
}
}
if (array_key_exists('PRICE_TO', $arFields)) {
$arFields["PRICE_TO"] = str_replace(",", ".", strval($arFields["PRICE_TO"]));
$arFields["PRICE_TO"] = doubleval($arFields["PRICE_TO"]);
if (0 < $arFields["PRICE_TO"]) {
$dblValue = roundEx($boolCurrency ? $arFields['PRICE_TO'] : CCurrencyRates::ConvertCurrency($arFields['PRICE_TO'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
$arConditions['CHILDREN'][] = array('CLASS_ID' => 'CondBsktAmtGroup', 'DATA' => array('logic' => 'EqLs', 'Value' => (string) $dblValue, 'All' => 'AND'), 'CHILDREN' => array());
$arFields["PRICE_TO"] = $dblValue;
}
}
if (self::OLD_DSC_TYPE_PERCENT == $arFields['DISCOUNT_TYPE']) {
$arActions['CHILDREN'][] = array('CLASS_ID' => 'ActSaleBsktGrp', 'DATA' => array('Type' => 'Discount', 'Value' => (string) roundEx($arFields['DISCOUNT_VALUE'], SALE_VALUE_PRECISION), 'Unit' => 'Perc', 'All' => 'AND'), 'CHILDREN' => array());
} else {
$dblValue = roundEx($boolCurrency ? $arFields['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arFields['DISCOUNT_VALUE'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
$arActions['CHILDREN'][] = array('CLASS_ID' => 'ActSaleBsktGrp', 'DATA' => array('Type' => 'Discount', 'Value' => (string) $dblValue, 'Unit' => 'CurAll', 'All' => 'AND'), 'CHILDREN' => array());
$arFields['DISCOUNT_VALUE'] = $dblValue;
}
$arFields['CONDITIONS'] = $arConditions;
$arFields['ACTIONS'] = $arActions;
$arFields['CURRENCY'] = $strSiteCurrency;
} else {
$obError = new CAdminException($arMsg);
$APPLICATION->ThrowException($obError);
}
}
}
return $boolResult;
}
示例9: array
}
}
}
}
}
}
$arCurrencyList = array();
$arDBCurrencies = array();
$dbCurrencyList = CCurrency::GetList($b = "", $o = "");
while ($arCurrency = $dbCurrencyList->Fetch()) {
$arDBCurrencies[$arCurrency["CURRENCY"]] = $arCurrency["AMOUNT_CNT"];
}
foreach ($arParams["arrCURRENCY_FROM"] as &$strCurrencyCode) {
if (array_key_exists($strCurrencyCode, $arDBCurrencies)) {
$arCurrencyList[] = $strCurrencyCode;
$rate = CCurrencyRates::ConvertCurrency($arDBCurrencies[$strCurrencyCode], $strCurrencyCode, $arParams["CURRENCY_BASE"], $arParams["RATE_DAY"]);
$arResult["CURRENCY"][] = array('FROM' => CurrencyFormat($arDBCurrencies[$strCurrencyCode], $strCurrencyCode), 'BASE' => CurrencyFormat($rate, $arParams["CURRENCY_BASE"]));
}
}
if (isset($strCurrencyCode)) {
unset($strCurrencyCode);
}
if (!empty($arCurrencyList)) {
if (defined("BX_COMP_MANAGED_CACHE")) {
$arCurrencyList[] = $arParams["CURRENCY_BASE"];
$arCurrencyList = array_unique($arCurrencyList);
$CACHE_MANAGER->StartTagCache($this->GetCachePath());
foreach ($arCurrencyList as &$strOneCurrency) {
$CACHE_MANAGER->RegisterTag("currency_id_" . $strOneCurrency);
}
if (isset($strOneCurrency)) {
示例10: FormatCurrency
{
//convert all prices to main element currency
foreach($arResult["SET_ITEMS"]["DEFAULT"] as $key=>$arItem)
{
$arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem['PRICE_DISCOUNT_VALUE'], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
$arResult["SET_ITEMS"]["PRICE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"];
$arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
$arResult["SET_ITEMS"]["OLD_PRICE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_VALUE"];
$arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
$arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"];
}
foreach($arResult["SET_ITEMS"]["OTHER"] as $key=>$arItem)
{
$arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem['PRICE_DISCOUNT_VALUE'], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
$arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
$arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
}
}
if ($arResult["SET_ITEMS"]["OLD_PRICE"] && $arResult["SET_ITEMS"]["OLD_PRICE"] != $arResult["SET_ITEMS"]["PRICE"])
$arResult["SET_ITEMS"]["OLD_PRICE"] = FormatCurrency($arResult["SET_ITEMS"]["OLD_PRICE"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
else
$arResult["SET_ITEMS"]["OLD_PRICE"] = 0;
if ($arResult["SET_ITEMS"]["PRICE"])
$arResult["SET_ITEMS"]["PRICE"] = FormatCurrency($arResult["SET_ITEMS"]["PRICE"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
if ($arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"])
$arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] = FormatCurrency($arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
示例11: htmlspecialcharsbx
if (strlen($noc) <= 0) {
$strErrorTmp .= "Please fill in \"Cardholder\" field. ";
}
$address1 = htmlspecialcharsbx(trim($_POST["address1"]));
if (strlen($address1) <= 0) {
$strErrorTmp .= "Please fill in \"Address\" field. ";
}
$zipcode = htmlspecialcharsbx(trim($_POST["zipcode"]));
if (strlen($zipcode) <= 0) {
$strErrorTmp .= "Please fill in \"Zip\" field. ";
}
if (strlen($strErrorTmp) <= 0) {
$ret_var = "";
$AMT = $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"];
if ($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"] != "USD") {
$AMT = CCurrencyRates::ConvertCurrency($AMT, $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"], "USD");
$additor = 1;
for ($i = 0; $i < SALE_VALUE_PRECISION; $i++) {
$additor = $additor / 10;
}
$AMT_tmp = round($AMT, SALE_VALUE_PRECISION);
while ($AMT_tmp < $AMT) {
$AMT_tmp = round($AMT_tmp + $additor, SALE_VALUE_PRECISION);
}
$AMT = $AMT_tmp;
}
$AMT = str_replace(",", ".", $AMT);
$cardExp = $cardexp1 . $cardexp2;
$parms = "ACCT=" . urlencode($cardnum);
// Credit card number
$parms .= "&CVV2=" . urlencode($cvv2);
示例12: calculateInReportCurrency
public static function calculateInReportCurrency($value)
{
$res = $value;
if (self::$reportCurrencyId != self::$siteCurrencyId) {
$res = \CCurrencyRates::ConvertCurrency($value, self::$siteCurrencyId, self::$reportCurrencyId);
}
return $res;
}
示例13: PayUserAccountDeliveryOrderCallback
function PayUserAccountDeliveryOrderCallback($productID, $userID, $bPaid, $orderID, $quantity = 1)
{
global $DB;
$productID = IntVal($productID);
$userID = IntVal($userID);
$bPaid = $bPaid ? True : False;
$orderID = IntVal($orderID);
if ($userID <= 0) {
return False;
}
if ($orderID <= 0) {
return False;
}
if (!($arOrder = CSaleOrder::GetByID($orderID))) {
return False;
}
$baseLangCurrency = CSaleLang::GetLangCurrency($arOrder["LID"]);
$arAmount = unserialize(COption::GetOptionString("sale", "pay_amount", 'a:4:{i:1;a:2:{s:6:"AMOUNT";s:2:"10";s:8:"CURRENCY";s:3:"EUR";}i:2;a:2:{s:6:"AMOUNT";s:2:"20";s:8:"CURRENCY";s:3:"EUR";}i:3;a:2:{s:6:"AMOUNT";s:2:"30";s:8:"CURRENCY";s:3:"EUR";}i:4;a:2:{s:6:"AMOUNT";s:2:"40";s:8:"CURRENCY";s:3:"EUR";}}'));
if (!array_key_exists($productID, $arAmount)) {
return False;
}
$currentPrice = $arAmount[$productID]["AMOUNT"] * $quantity;
$currentCurrency = $arAmount[$productID]["CURRENCY"];
if ($arAmount[$productID]["CURRENCY"] != $baseLangCurrency) {
$currentPrice = CCurrencyRates::ConvertCurrency($arAmount[$productID]["AMOUNT"], $arAmount[$productID]["CURRENCY"], $baseLangCurrency) * $quantity;
$currentCurrency = $baseLangCurrency;
}
if (!CSaleUserAccount::UpdateAccount($userID, $bPaid ? $currentPrice : -$currentPrice, $currentCurrency, "MANUAL", $orderID, "Payment to user account")) {
return False;
}
return True;
}
示例14: fGetFormatedProduct
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
global $crmMode;
$result = "";
$arSet = array();
if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 0)
return $result;
$result = "<table width=\"100%\">";
if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock'))
{
$arProductId = array();
$arDataTab = array();
$arSkuParentChildren = array();
$arSkuParentId = array();
$arSkuParent = array();
foreach ($arData["ITEMS"] as $item)
{
if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
{
if (floatval($item["PRICE"]) > 0)
$item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);
if (floatval($item["DISCOUNT_PRICE"]) > 0)
$item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);
$item["CURRENCY"] = $currency;
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($item))
{
if (method_exists($productProvider, "GetSetItems"))
{
$itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
$arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
unset($itemInfo);
if (is_array($arSets))
{
foreach ($arSets as $arSetData)
{
foreach ($arSetData["ITEMS"] as $setItem)
{
$setItem["FUSER_ID"] = $item["FUSER_ID"];
$setItem["LID"] = $item["LID"];
$setItem["MODULE"] = $item["MODULE"];
$setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
$setItem["SET_PARENT_ID"] = $item["ID"];
$arSet[$item["PRODUCT_ID"]][] = $setItem;
}
}
}
}
}
if ($item["MODULE"] == "catalog")
{
$arProductId[$item["PRODUCT_ID"]] = $item["PRODUCT_ID"];
$arDataTab[$item["PRODUCT_ID"]] = $item;
$arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
if ($arParent)
{
$arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
$arSkuParentId[$arParent["ID"]] = $arParent["ID"];
}
}
}
if(!empty($arSkuParentId))
{
$res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
while ($arItems = $res->GetNext())
$arSkuParent[$arItems["ID"]] = $arItems;
}
if(!empty($arProductId))
{
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
while($arProduct = $dbProduct->Fetch())
{
$imgCode = 0;
$arImgProduct = false;
$arFile = false;
$imgUrl = '';
$imgProduct = '';
$arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
$arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
$arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
$arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
$arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
$item = $arDataTab[$arProduct['ID']];
if ($item["PREVIEW_PICTURE"] == "" && $item["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$item["PRODUCT_ID"]]))
{
//.........这里部分代码省略.........
示例15: GetProductSku
/**
* get sku for product.
*
* @param integer $USER_ID User.
* @param string $LID Site.
* @param integer $PRODUCT_ID Product id.
* @param string $PRODUCT_NAME Product name.
* @param string CURRENCY Currency.
* @param array $arProduct Iblock list.
* @return array|false
*/
function GetProductSku($USER_ID, $LID, $PRODUCT_ID, $PRODUCT_NAME = '', $CURRENCY = '', $arProduct = array())
{
$USER_ID = (int) $USER_ID;
$PRODUCT_ID = (int) $PRODUCT_ID;
if ($PRODUCT_ID <= 0) {
return false;
}
$LID = trim($LID);
if ($LID == '') {
return false;
}
$PRODUCT_NAME = trim($PRODUCT_NAME);
$arResult = array();
$arOffers = array();
static $arCacheGroups = array();
if (!is_set($arCacheGroups[$USER_ID])) {
$arCacheGroups[$USER_ID] = CUser::GetUserGroup($USER_ID);
}
$arGroups = $arCacheGroups[$USER_ID];
if (empty($arProduct)) {
$arProduct = CSaleProduct::GetProductListIblockInfo(array($PRODUCT_ID));
}
static $arOffersIblock = array();
if (!is_set($arOffersIblock[$arProduct["IBLOCK_ID"]])) {
$mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]);
if (is_array($mxResult)) {
$arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"];
}
}
if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0) {
static $arCacheOfferProperties = array();
if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]])) {
$dbOfferProperties = CIBlock::GetProperties($arOffersIblock[$arProduct["IBLOCK_ID"]], array(), array("!XML_ID" => "CML2_LINK"));
while ($arOfferProperties = $dbOfferProperties->Fetch()) {
$arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties;
}
}
$arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]];
$arIblockOfferProps = array();
$arIblockOfferPropsFilter = array();
if (is_array($arOfferProperties)) {
foreach ($arOfferProperties as $val) {
$arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
$arIblockOfferPropsFilter[] = $val["CODE"];
}
}
$arOffers = CIBlockPriceTools::GetOffersArray($arProduct["IBLOCK_ID"], $PRODUCT_ID, array("ID" => "DESC"), array("NAME"), $arIblockOfferPropsFilter, 0, array(), 1, array(), $USER_ID, $LID);
$arSku = array();
$minItemPrice = 0;
$minItemPriceFormat = "";
$arSkuId = array();
$arImgSku = array();
foreach ($arOffers as $arOffer) {
$arSkuId[] = $arOffer['ID'];
}
if (!empty($arSkuId)) {
$res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL"));
while ($arOfferImg = $res->GetNext()) {
$arImgSku[$arOfferImg["ID"]] = $arOfferImg;
}
}
foreach ($arOffers as $arOffer) {
$arPrice = CCatalogProduct::GetOptimalPrice($arOffer['ID'], 1, $arGroups, "N", array(), $LID);
if (empty($arPrice)) {
break;
} elseif (strlen($CURRENCY) > 0) {
$arPrice["PRICE"]["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
if ($arPrice["DISCOUNT_PRICE"] > 0) {
$arPrice["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
}
$arPrice["PRICE"]["CURRENCY"] = $CURRENCY;
}
$arSkuTmp = array();
$arOffer["CAN_BUY"] = "N";
$arCatalogProduct = CCatalogProduct::GetByID($arOffer['ID']);
if (!empty($arCatalogProduct)) {
if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
$arOffer["CAN_BUY"] = "N";
} else {
$arOffer["CAN_BUY"] = "Y";
}
}
$arSkuTmp["ImageUrl"] = '';
if ($arOffer["CAN_BUY"] == "Y") {
$productImg = "";
if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']])) {
if ('' == $PRODUCT_NAME) {
$PRODUCT_NAME = $arImgSku[$arOffer['ID']]["~NAME"];
}
//.........这里部分代码省略.........