本文整理汇总了PHP中CCatalogProduct::GetVATInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProduct::GetVATInfo方法的具体用法?PHP CCatalogProduct::GetVATInfo怎么用?PHP CCatalogProduct::GetVATInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogProduct
的用法示例。
在下文中一共展示了CCatalogProduct::GetVATInfo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetProductData
//.........这里部分代码省略.........
} else {
CCatalogDiscountSave::Enable();
}
}
if (empty($arPrice)) {
return $arResult;
}
$arDiscountList = array();
if (empty($arPrice['DISCOUNT_LIST']) && !empty($arPrice['DISCOUNT']) && is_array($arPrice['DISCOUNT'])) {
$arPrice['DISCOUNT_LIST'] = array($arPrice['DISCOUNT']);
}
if (!empty($arPrice['DISCOUNT_LIST'])) {
$appliedCoupons = array();
foreach ($arPrice['DISCOUNT_LIST'] as &$arOneDiscount) {
$arOneList = array('ID' => $arOneDiscount['ID'], 'NAME' => $arOneDiscount['NAME'], 'COUPON' => '', 'COUPON_TYPE' => '', 'USE_COUPONS' => isset($arOneDiscount['USE_COUPONS']) ? $arOneDiscount['USE_COUPONS'] : 'N', 'MODULE_ID' => isset($oneDiscount['MODULE_ID']) ? $oneDiscount['MODULE_ID'] : 'catalog', 'TYPE' => $arOneDiscount['TYPE'], 'VALUE' => $arOneDiscount['VALUE'], 'VALUE_TYPE' => $arOneDiscount['VALUE_TYPE'], 'MAX_VALUE' => $arOneDiscount['VALUE_TYPE'] == Catalog\DiscountTable::VALUE_TYPE_PERCENT ? $arOneDiscount['MAX_DISCOUNT'] : 0, 'CURRENCY' => $arOneDiscount['CURRENCY'], 'HANDLERS' => isset($arOneDiscount['HANDLERS']) ? $arOneDiscount['HANDLERS'] : array());
if (!empty($arOneDiscount['COUPON'])) {
$arOneList['USE_COUPONS'] = 'Y';
$arOneList['COUPON'] = $arOneDiscount['COUPON'];
$arOneList['COUPON_TYPE'] = $arOneDiscount['COUPON_ONE_TIME'];
$appliedCoupons[] = $arOneDiscount['COUPON'];
}
$arDiscountList[] = $arOneList;
}
unset($arOneList, $arOneDiscount);
if (!empty($appliedCoupons)) {
$resultApply = DiscountCouponsManager::setApplyByProduct($productHash, $appliedCoupons);
}
unset($resultApply, $appliedCoupons);
}
if (empty($arPrice['PRICE']['CATALOG_GROUP_NAME'])) {
if (!empty($arPrice['PRICE']['CATALOG_GROUP_ID'])) {
$priceName = self::getPriceTitle($arPrice['PRICE']['CATALOG_GROUP_ID']);
if ($priceName != '') {
$arPrice['PRICE']['CATALOG_GROUP_NAME'] = $priceName;
}
unset($priceName);
}
}
} else {
$vatRate = 0.0;
if (!($arVAT = static::getHitCache('VAT_INFO', $productID))) {
$rsVAT = CCatalogProduct::GetVATInfo($productID);
if ($arVAT = $rsVAT->Fetch()) {
static::setHitCache('VAT_INFO', $productID, $arVAT);
}
unset($rsVAT);
}
if (!empty($arVAT) && is_array($arVAT)) {
$vatRate = (double) $arVAT['RATE'] * 0.01;
}
}
$arResult = array("NAME" => $arProduct["~NAME"], "CAN_BUY" => "Y", "DETAIL_PAGE_URL" => $arProduct['~DETAIL_PAGE_URL'], "BARCODE_MULTI" => $arCatalogProduct["BARCODE_MULTI"], "WEIGHT" => (double) $arCatalogProduct['WEIGHT'], "DIMENSIONS" => serialize(array("WIDTH" => $arCatalogProduct["WIDTH"], "HEIGHT" => $arCatalogProduct["HEIGHT"], "LENGTH" => $arCatalogProduct["LENGTH"])), "TYPE" => $arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET ? CCatalogProductSet::TYPE_SET : null);
if ($arParams['SELECT_QUANTITY_TRACE'] == "Y") {
$arResult["QUANTITY_TRACE"] = $arCatalogProduct["QUANTITY_TRACE"];
}
if ($arParams["CHECK_QUANTITY"] == "Y") {
$arResult["QUANTITY"] = $boolQuantity && $dblQuantity < $quantity ? $dblQuantity : $quantity;
} else {
$arResult["QUANTITY"] = $arParams["QUANTITY"];
}
if ($arParams["CHECK_QUANTITY"] == "Y" && $boolQuantity && $dblQuantity < $quantity) {
$APPLICATION->ThrowException(Loc::getMessage("CATALOG_QUANTITY_NOT_ENOGH", array("#NAME#" => htmlspecialcharsbx($arProduct["~NAME"]), "#CATALOG_QUANTITY#" => $arCatalogProduct["QUANTITY"], "#QUANTITY#" => $quantity)), "CATALOG_QUANTITY_NOT_ENOGH");
}
if ($arParams['CHECK_PRICE'] == 'Y') {
$arResult['PRODUCT_PRICE_ID'] = $arPrice['PRICE']['ID'];
$arResult['NOTES'] = $arPrice['PRICE']['CATALOG_GROUP_NAME'];
$arResult['VAT_RATE'] = $arPrice['PRICE']['VAT_RATE'];
$arResult['DISCOUNT_NAME'] = '';
$arResult['DISCOUNT_COUPON'] = '';
$arResult['DISCOUNT_LIST'] = array();
if (empty($arPrice['RESULT_PRICE']) || !is_array($arPrice['RESULT_PRICE'])) {
$arPrice['RESULT_PRICE'] = CCatalogDiscount::calculateDiscountList($arPrice['PRICE'], $arParams['CURRENCY'], $arDiscountList, true);
}
$arResult['BASE_PRICE'] = $arPrice['RESULT_PRICE']['BASE_PRICE'];
$arResult['PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
$arResult['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY'];
$arResult['DISCOUNT_PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT'];
if (isset($arPrice['RESULT_PRICE']['PERCENT'])) {
$arResult['DISCOUNT_VALUE'] = $arPrice['RESULT_PRICE']['PERCENT'] > 0 ? $arPrice['RESULT_PRICE']['PERCENT'] . '%' : 0;
} else {
$arResult['DISCOUNT_VALUE'] = $arPrice['RESULT_PRICE']['DISCOUNT_VALUE'];
}
if (!empty($arDiscountList)) {
$arResult['DISCOUNT_LIST'] = $arDiscountList;
}
if (!empty($arPrice['DISCOUNT'])) {
$arResult['DISCOUNT_NAME'] = '[' . $arPrice['DISCOUNT']['ID'] . '] ' . $arPrice['DISCOUNT']['NAME'];
if (!empty($arPrice['DISCOUNT']['COUPON'])) {
$arResult['DISCOUNT_COUPON'] = $arPrice['DISCOUNT']['COUPON'];
}
if (empty($arResult['DISCOUNT_LIST'])) {
$arResult['DISCOUNT_LIST'] = array($arPrice['DISCOUNT']);
}
}
} else {
$arResult['VAT_RATE'] = $vatRate;
}
$arResult["VAT_INCLUDED"] = "Y";
return $arResult;
}
示例2: GetOptimalPrice
//.........这里部分代码省略.........
global $APPLICATION;
$mxResult = true;
foreach (GetModuleEvents("catalog", "OnGetOptimalPrice", true) as $arEvent)
{
$mxResult = ExecuteModuleEventEx($arEvent, array($intProductID, $quantity, $arUserGroups, $renewal, $arPrices, $siteID, $arDiscountCoupons));
if (true !== $mxResult)
return $mxResult;
}
$intProductID = intval($intProductID);
if (0 >= $intProductID)
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_PROD_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
return false;
}
$quantity = doubleval($quantity);
if (0 >= $quantity)
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_PROD_ERR_QUANTITY_ABSENT"), "NO_QUANTITY");
return false;
}
if (!is_array($arUserGroups) && intval($arUserGroups)."|" == $arUserGroups."|")
$arUserGroups = array(intval($arUserGroups));
if (!is_array($arUserGroups))
$arUserGroups = array();
if (!in_array(2, $arUserGroups))
$arUserGroups[] = 2;
$rsVAT = CCatalogProduct::GetVATInfo($intProductID);
if ($arVAT = $rsVAT->Fetch())
{
$arVAT['RATE'] = doubleval($arVAT['RATE'] * 0.01);
}
else
{
$arVAT = array('RATE' => 0.0, 'VAT_INCLUDED' => 'N');
}
$renewal = (($renewal == "N") ? "N" : "Y");
if (false === $siteID)
$siteID = SITE_ID;
if (false === $arDiscountCoupons)
$arDiscountCoupons = CCatalogDiscountCoupon::GetCoupons();
$strBaseCurrency = CCurrency::GetBaseCurrency();
if (empty($strBaseCurrency))
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_PROD_ERR_NO_BASE_CURRENCY"), "NO_BASE_CURRENCY");
return false;
}
$intIBlockID = intval(CIBlockElement::GetIBlockByID($intProductID));
if (0 >= $intIBlockID)
{
$APPLICATION->ThrowException(str_replace("#ID#", $intProductID, GetMessage('BT_MOD_CATALOG_PROD_ERR_ELEMENT_ID_NOT_FOUND')), "NO_ELEMENT");
return false;
}
if (!isset($arPrices) || !is_array($arPrices))
示例3: CatalogGetPriceTableEx
function CatalogGetPriceTableEx($ID, $filterQauntity = 0, $arFilterType = array(), $VAT_INCLUDE = 'Y', $arCurrencyParams = array())
{
global $USER;
static $arPriceTypes = array();
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
$filterQauntity = (int) $filterQauntity;
if (!is_array($arFilterType)) {
$arFilterType = array($arFilterType);
}
$boolConvert = false;
$strCurrencyID = '';
$arCurrencyList = array();
if (!empty($arCurrencyParams) && is_array($arCurrencyParams) && !empty($arCurrencyParams['CURRENCY_ID'])) {
$boolConvert = true;
$strCurrencyID = $arCurrencyParams['CURRENCY_ID'];
}
$arResult = array();
$arResult["ROWS"] = array();
$arResult["COLS"] = array();
$arResult["MATRIX"] = array();
$arResult["CAN_BUY"] = array();
$arResult["AVAILABLE"] = "N";
$cacheTime = CATALOG_CACHE_DEFAULT_TIME;
if (defined("CATALOG_CACHE_TIME")) {
$cacheTime = intval(CATALOG_CACHE_TIME);
}
$arUserGroups = $USER->GetUserGroupArray();
CatalogClearArray($arUserGroups, true);
$strCacheID = 'UG_' . implode('_', $arUserGroups);
if (isset($arPriceTypes[$strCacheID])) {
$arPriceGroups = $arPriceTypes[$strCacheID];
} else {
$arPriceGroups = CCatalogGroup::GetGroupsPerms($arUserGroups, array());
$arPriceTypes[$strCacheID] = $arPriceGroups;
}
if (empty($arPriceGroups["view"])) {
return $arResult;
}
$currentQuantity = -1;
$rowsCnt = -1;
$arFilter = array("PRODUCT_ID" => $ID);
if ($filterQauntity > 0) {
$arFilter["+<=QUANTITY_FROM"] = $filterQauntity;
$arFilter["+>=QUANTITY_TO"] = $filterQauntity;
}
if (!empty($arFilterType)) {
$arTmp = array();
foreach ($arPriceGroups["view"] as &$intOneGroup) {
if (in_array($intOneGroup, $arFilterType)) {
$arTmp[] = $intOneGroup;
}
}
if (isset($intOneGroup)) {
unset($intOneGroup);
}
if (empty($arTmp)) {
return $arResult;
}
$arFilter["CATALOG_GROUP_ID"] = $arTmp;
} else {
$arFilter["CATALOG_GROUP_ID"] = $arPriceGroups["view"];
}
$productQuantity = 0;
$productQuantityTrace = "N";
$dbRes = CCatalogProduct::GetVATInfo($ID);
if ($arVatInfo = $dbRes->Fetch()) {
$fVatRate = floatval($arVatInfo['RATE'] * 0.01);
$bVatIncluded = $arVatInfo['VAT_INCLUDED'] == 'Y';
} else {
$fVatRate = 0.0;
$bVatIncluded = false;
}
$rsProducts = CCatalogProduct::GetList(array(), array('ID' => $ID), false, false, array('ID', 'CAN_BUY_ZERO', 'QUANTITY_TRACE', 'QUANTITY'));
if ($arProduct = $rsProducts->Fetch()) {
$intIBlockID = CIBlockElement::GetIBlockByID($arProduct['ID']);
if (!$intIBlockID) {
return false;
}
$arProduct['IBLOCK_ID'] = $intIBlockID;
} else {
return false;
}
$dbPrice = CPrice::GetListEx(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"), $arFilter, false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO"));
while ($arPrice = $dbPrice->Fetch()) {
if ($VAT_INCLUDE == 'N') {
if ($bVatIncluded) {
$arPrice['PRICE'] /= 1 + $fVatRate;
}
} else {
if (!$bVatIncluded) {
$arPrice['PRICE'] *= 1 + $fVatRate;
}
}
$arPrice['VAT_RATE'] = $fVatRate;
CCatalogDiscountSave::Disable();
$arDiscounts = CCatalogDiscount::GetDiscount($ID, $arProduct["IBLOCK_ID"], $arPrice["CATALOG_GROUP_ID"], $arUserGroups, "N", SITE_ID, array());
CCatalogDiscountSave::Enable();
//.........这里部分代码省略.........
示例4: GetProductData
//.........这里部分代码省略.........
'VALUE' => $arOneDiscount['VALUE'],
'VALUE_TYPE' => $arOneDiscount['VALUE_TYPE'],
'CURRENCY' => $arOneDiscount['CURRENCY'],
'HANDLERS' => (isset($arOneDiscount['HANDLERS']) ? $arOneDiscount['HANDLERS'] : array())
);
if ($arOneDiscount['COUPON'])
{
$arOneList['COUPON'] = $arOneDiscount['COUPON'];
$arOneList['COUPON_TYPE'] = $arOneDiscount['COUPON_ONE_TIME'];
if ($arOneDiscount['COUPON_ONE_TIME'] == CCatalogDiscountCoupon::TYPE_ONE_TIME)
{
self::$arOneTimeCoupons[$arOneDiscount['COUPON']] = $strBasketProductID;
}
}
$arDiscountList[] = $arOneList;
}
unset($arOneList, $arOneDiscount);
}
if (empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]))
{
if (!empty($arPrice["PRICE"]["CATALOG_GROUP_ID"]))
{
$rsCatGroups = CCatalogGroup::GetListEx(array(),array('ID' => $arPrice["PRICE"]["CATALOG_GROUP_ID"]),false,false,array('ID','NAME','NAME_LANG'));
if ($arCatGroup = $rsCatGroups->Fetch())
{
$arPrice["PRICE"]["CATALOG_GROUP_NAME"] = (!empty($arCatGroup['NAME_LANG']) ? $arCatGroup['NAME_LANG'] : $arCatGroup['NAME']);
}
}
}
}
else
{
$rsVAT = CCatalogProduct::GetVATInfo($productID);
if ($arVAT = $rsVAT->Fetch())
{
$vatRate = doubleval($arVAT['RATE'] * 0.01);
}
else
{
$vatRate = 0.0;
}
}
$arResult = array(
"NAME" => $arProduct["~NAME"],
"CAN_BUY" => "Y",
"DETAIL_PAGE_URL" => $arProduct['~DETAIL_PAGE_URL'],
"BARCODE_MULTI" => $arCatalogProduct["BARCODE_MULTI"],
"WEIGHT" => floatval($arCatalogProduct['WEIGHT']),
"DIMENSIONS" => serialize(array(
"WIDTH" => $arCatalogProduct["WIDTH"],
"HEIGHT" => $arCatalogProduct["HEIGHT"],
"LENGTH" => $arCatalogProduct["LENGTH"]
)),
"TYPE" => ($arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET) ? CCatalogProductSet::TYPE_SET : NULL
);
if ($arParams["CHECK_QUANTITY"] == "Y")
$arResult["QUANTITY"] = ($boolQuantity && $dblQuantity < $quantity) ? $dblQuantity : $quantity;
else
$arResult["QUANTITY"] = $arParams["QUANTITY"];
if ($arParams["CHECK_QUANTITY"] == "Y" && $boolQuantity && $dblQuantity < $quantity)
$APPLICATION->ThrowException(Loc::getMessage("CATALOG_QUANTITY_NOT_ENOGH", array("#NAME#" => htmlspecialcharsbx($arProduct["~NAME"]), "#CATALOG_QUANTITY#" => $arCatalogProduct["QUANTITY"], "#QUANTITY#" => $quantity)), "CATALOG_QUANTITY_NOT_ENOGH");
if ($arParams["CHECK_PRICE"] == "Y")
{
$arResult = array_merge($arResult, array(
"PRODUCT_PRICE_ID" => $arPrice["PRICE"]["ID"],
'BASE_PRICE' => $arPrice['RESULT_PRICE']['BASE_PRICE'],
"PRICE" => $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'],
"CURRENCY" => $arPrice['RESULT_PRICE']['CURRENCY'],
"DISCOUNT_PRICE" => $arPrice['RESULT_PRICE']['DISCOUNT'],
"NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"],
"VAT_RATE" => $arPrice["PRICE"]["VAT_RATE"],
"DISCOUNT_VALUE" => ($arPrice['RESULT_PRICE']['PERCENT'] > 0 ? $arPrice['RESULT_PRICE']['PERCENT'].'%' : 0),
"DISCOUNT_NAME" => '',
"DISCOUNT_COUPON" => '',
"DISCOUNT_LIST" => array()
));
if (!empty($arDiscountList))
{
$arResult['DISCOUNT_LIST'] = $arDiscountList;
$arResult["DISCOUNT_NAME"] = "[".$arPrice["DISCOUNT"]["ID"]."] ".$arPrice["DISCOUNT"]["NAME"];
if (!empty($arPrice["DISCOUNT"]["COUPON"]))
{
$arResult["DISCOUNT_COUPON"] = $arPrice["DISCOUNT"]["COUPON"];
}
}
}
else
{
$arResult["VAT_RATE"] = $vatRate;
}
return $arResult;
}
示例5: GetOptimalPrice
//.........这里部分代码省略.........
$resultCurrency = CCurrency::GetBaseCurrency();
if (empty($resultCurrency)) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_PROD_ERR_NO_BASE_CURRENCY"), "NO_BASE_CURRENCY");
return false;
}
if (self::$usedCurrency !== null) {
$resultCurrency = self::$usedCurrency;
}
$intIBlockID = (int) CIBlockElement::GetIBlockByID($intProductID);
if ($intIBlockID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_PROD_ERR_ELEMENT_ID_NOT_FOUND', array('#ID#' => $intProductID)), 'NO_ELEMENT');
return false;
}
if (!isset($arPrices) || !is_array($arPrices)) {
$arPrices = array();
}
if (empty($arPrices)) {
$arPrices = array();
$dbPriceList = CPrice::GetListEx(array(), array("PRODUCT_ID" => $intProductID, "GROUP_GROUP_ID" => $arUserGroups, "GROUP_BUY" => "Y", "+<=QUANTITY_FROM" => $quantity, "+>=QUANTITY_TO" => $quantity), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY"));
while ($arPriceList = $dbPriceList->Fetch()) {
$arPriceList['ELEMENT_IBLOCK_ID'] = $intIBlockID;
$arPrices[] = $arPriceList;
}
unset($arPriceList, $dbPriceList);
} else {
foreach ($arPrices as &$arOnePrice) {
$arOnePrice['ELEMENT_IBLOCK_ID'] = $intIBlockID;
}
unset($arOnePrice);
}
if (empty($arPrices)) {
return false;
}
$rsVAT = CCatalogProduct::GetVATInfo($intProductID);
if ($arVAT = $rsVAT->Fetch()) {
$arVAT['RATE'] = (double) $arVAT['RATE'] * 0.01;
} else {
$arVAT = array('RATE' => 0.0, 'VAT_INCLUDED' => 'N');
}
unset($rsVAT);
if (self::getUseDiscount()) {
if ($arDiscountCoupons === false) {
$arDiscountCoupons = CCatalogDiscountCoupon::GetCoupons();
}
}
// $boolDiscountVat = ('N' != COption::GetOptionString('catalog', 'discount_vat', 'Y'));
$boolDiscountVat = true;
$minPrice = false;
$basePrice = false;
$arMinPrice = array();
$arMinDiscounts = array();
foreach ($arPrices as &$arPriceList) {
$arPriceList['VAT_RATE'] = $arVAT['RATE'];
$arPriceList['VAT_INCLUDED'] = $arVAT['VAT_INCLUDED'];
$dblCurrentPrice = $arPriceList['PRICE'];
if ($boolDiscountVat) {
if ('N' == $arPriceList['VAT_INCLUDED']) {
$dblCurrentPrice *= 1 + $arPriceList['VAT_RATE'];
}
} else {
if ('Y' == $arPriceList['VAT_INCLUDED']) {
$dblCurrentPrice /= 1 + $arPriceList['VAT_RATE'];
}
}
if ($arPriceList['CURRENCY'] != $resultCurrency) {
$dblCurrentPrice = CCurrencyRates::ConvertCurrency($arPriceList['PRICE'], $arPriceList['CURRENCY'], $resultCurrency);
示例6: CatalogGetPriceTableEx
//.........这里部分代码省略.........
$currentQuantity = -1;
$rowsCnt = -1;
$arFilter = array("PRODUCT_ID" => $ID);
if ($filterQauntity > 0)
{
$arFilter["+<=QUANTITY_FROM"] = $filterQauntity;
$arFilter["+>=QUANTITY_TO"] = $filterQauntity;
}
if (!empty($arFilterType))
{
$arTmp = array();
foreach ($arPriceGroups["view"] as &$intOneGroup)
{
if (in_array($intOneGroup, $arFilterType))
$arTmp[] = $intOneGroup;
}
if (isset($intOneGroup))
unset($intOneGroup);
if (empty($arTmp))
return $arResult;
$arFilter["CATALOG_GROUP_ID"] = $arTmp;
}
else
{
$arFilter["CATALOG_GROUP_ID"] = $arPriceGroups["view"];
}
$productQuantity = 0;
$productQuantityTrace = "N";
$dbRes = CCatalogProduct::GetVATInfo($ID);
if ($arVatInfo = $dbRes->Fetch())
{
$fVatRate = floatval($arVatInfo['RATE'] * 0.01);
$bVatIncluded = $arVatInfo['VAT_INCLUDED'] == 'Y';
}
else
{
$fVatRate = 0.00;
$bVatIncluded = false;
}
$dbPrice = CPrice::GetListEx(
array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"),
$arFilter,
false,
false,
array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO", "PRODUCT_QUANTITY", "PRODUCT_QUANTITY_TRACE", "PRODUCT_CAN_BUY_ZERO", "ELEMENT_IBLOCK_ID")
);
while ($arPrice = $dbPrice->Fetch())
{
if ($VAT_INCLUDE == 'N')
{
if ($bVatIncluded)
$arPrice['PRICE'] /= (1 + $fVatRate);
}
else
{
if (!$bVatIncluded)
$arPrice['PRICE'] *= (1 + $fVatRate);
}
示例7: GetProductData
//.........这里部分代码省略.........
}
}
$arDiscountList = array();
if (!empty($arPrice["DISCOUNT_LIST"])) {
$dblStartPrice = $currentPrice;
foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
switch ($arOneDiscount['VALUE_TYPE']) {
case CCatalogDiscount::TYPE_FIX:
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$currentDiscount = $arOneDiscount['VALUE'];
} else {
$currentDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
$currentPrice = $currentPrice - $currentDiscount;
break;
case CCatalogDiscount::TYPE_PERCENT:
$currentDiscount = $currentPrice * $arOneDiscount["VALUE"] / 100.0;
if (0 < $arOneDiscount['MAX_DISCOUNT']) {
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$dblMaxDiscount = $arOneDiscount['MAX_DISCOUNT'];
} else {
$dblMaxDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount['MAX_DISCOUNT'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
if ($currentDiscount > $dblMaxDiscount) {
$currentDiscount = $dblMaxDiscount;
}
}
$currentPrice = $currentPrice - $currentDiscount;
break;
case CCatalogDiscount::TYPE_SALE:
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$currentPrice = $arOneDiscount['VALUE'];
} else {
$currentPrice = CCurrencyRates::ConvertCurrency($arOneDiscount['VALUE'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
break;
}
$arOneList = array('ID' => $arOneDiscount['ID'], 'NAME' => $arOneDiscount['NAME'], 'COUPON' => '', 'COUPON_TYPE' => '', 'MODULE_ID' => 'catalog', 'TYPE' => $arOneDiscount['TYPE'], 'VALUE' => $arOneDiscount['VALUE'], 'VALUE_TYPE' => $arOneDiscount['VALUE_TYPE'], 'CURRENCY' => $arOneDiscount['CURRENCY'], 'HANDLERS' => isset($arOneDiscount['HANDLERS']) ? $arOneDiscount['HANDLERS'] : array());
if ($arOneDiscount['COUPON']) {
$arOneList['COUPON'] = $arOneDiscount['COUPON'];
$arOneList['COUPON_TYPE'] = $arOneDiscount['COUPON_ONE_TIME'];
if ($arOneDiscount['COUPON_ONE_TIME'] == CCatalogDiscountCoupon::TYPE_ONE_TIME) {
self::$arOneTimeCoupons[$arOneDiscount['COUPON']] = $strBasketProductID;
}
}
$arDiscountList[] = $arOneList;
}
if (isset($arOneDiscount)) {
unset($arOneDiscount);
}
$currentDiscount = $dblStartPrice - $currentPrice;
}
if (empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"])) {
if (!empty($arPrice["PRICE"]["CATALOG_GROUP_ID"])) {
$rsCatGroups = CCatalogGroup::GetListEx(array(), array('ID' => $arPrice["PRICE"]["CATALOG_GROUP_ID"]), false, false, array('ID', 'NAME', 'NAME_LANG'));
if ($arCatGroup = $rsCatGroups->Fetch()) {
$arPrice["PRICE"]["CATALOG_GROUP_NAME"] = !empty($arCatGroup['NAME_LANG']) ? $arCatGroup['NAME_LANG'] : $arCatGroup['NAME'];
}
}
}
if (!$boolDiscountVat) {
$currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
$currentDiscount *= 1 + $arPrice['PRICE']['VAT_RATE'];
$arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
}
} else {
$rsVAT = CCatalogProduct::GetVATInfo($productID);
if ($arVAT = $rsVAT->Fetch()) {
$vatRate = doubleval($arVAT['RATE'] * 0.01);
} else {
$vatRate = 0.0;
}
}
$arResult = array("NAME" => $arProduct["~NAME"], "CAN_BUY" => "Y", "DETAIL_PAGE_URL" => $arProduct['~DETAIL_PAGE_URL'], "BARCODE_MULTI" => $arCatalogProduct["BARCODE_MULTI"], "WEIGHT" => floatval($arCatalogProduct['WEIGHT']), "DIMENSIONS" => serialize(array("WIDTH" => $arCatalogProduct["WIDTH"], "HEIGHT" => $arCatalogProduct["HEIGHT"], "LENGTH" => $arCatalogProduct["LENGTH"])), "TYPE" => $arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET ? CCatalogProductSet::TYPE_SET : NULL);
if ($arParams["CHECK_QUANTITY"] == "Y") {
$arResult["QUANTITY"] = $boolQuantity && $dblQuantity < $quantity ? $dblQuantity : $quantity;
} else {
$arResult["QUANTITY"] = $arParams["QUANTITY"];
}
if ($arParams["CHECK_QUANTITY"] == "Y" && $boolQuantity && $dblQuantity < $quantity) {
$APPLICATION->ThrowException(Loc::getMessage("CATALOG_QUANTITY_NOT_ENOGH", array("#NAME#" => htmlspecialcharsbx($arProduct["~NAME"]), "#CATALOG_QUANTITY#" => $arCatalogProduct["QUANTITY"], "#QUANTITY#" => $quantity)), "CATALOG_QUANTITY_NOT_ENOGH");
}
if (0 < $intUserID) {
CCatalogDiscountSave::ClearDiscountUserID();
}
if ($arParams["CHECK_PRICE"] == "Y") {
$arResult = array_merge($arResult, array("PRODUCT_PRICE_ID" => $arPrice["PRICE"]["ID"], "PRICE" => $currentPrice, "CURRENCY" => $arPrice["PRICE"]["CURRENCY"], "DISCOUNT_PRICE" => $currentDiscount, "NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "VAT_RATE" => $arPrice["PRICE"]["VAT_RATE"], "DISCOUNT_VALUE" => 0, "DISCOUNT_NAME" => "", "DISCOUNT_COUPON" => "", "DISCOUNT_LIST" => array()));
if (!empty($arDiscountList)) {
$arResult['DISCOUNT_LIST'] = $arDiscountList;
$arResult["DISCOUNT_VALUE"] = 100 * $currentDiscount / ($currentDiscount + $currentPrice) . "%";
$arResult["DISCOUNT_NAME"] = "[" . $arPrice["DISCOUNT"]["ID"] . "] " . $arPrice["DISCOUNT"]["NAME"];
if (!empty($arPrice["DISCOUNT"]["COUPON"])) {
$arResult["DISCOUNT_COUPON"] = $arPrice["DISCOUNT"]["COUPON"];
}
}
} else {
$arResult["VAT_RATE"] = $vatRate;
}
return $arResult;
}