本文整理汇总了PHP中CCatalogProduct::GetOptimalPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProduct::GetOptimalPrice方法的具体用法?PHP CCatalogProduct::GetOptimalPrice怎么用?PHP CCatalogProduct::GetOptimalPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogProduct
的用法示例。
在下文中一共展示了CCatalogProduct::GetOptimalPrice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPriceObj
protected function getPriceObj()
{
if ($this->price === null) {
$this->price = \CCatalogProduct::GetOptimalPrice($this->ID);
// echo '<pre>'.print_r($this->price,true).'</pre>';
}
return $this->price;
}
示例2: get_ib_items_list
private static function get_ib_items_list($arFilter, $arSelectFields, $with_prices = false)
{
if (!CModule::IncludeModule("iblock")) {
return false;
}
$arItems = array();
$res = CIBlockElement::GetList(array("SORT" => "ASC", "NAME" => "ASC"), $arFilter, false, false, $arSelectFields);
while ($item = $res->GetNext()) {
if ($with_prices) {
$item["PRICE"] = CCatalogProduct::GetOptimalPrice($item["ID"], self::DEFAULT_PRICE_ID, isset($GLOBALS['USER']) && $GLOBALS['USER'] ? $GLOBALS['USER']->GetUserGroupArray() : 0);
if (isset($item["PRICE"]["RESULT_PRICE"]) && $item["PRICE"]["RESULT_PRICE"]) {
$item["PRICE_VALUE"] = $item["PRICE"]["RESULT_PRICE"]["BASE_PRICE"];
$item["PRICE_STR_VALUE"] = CurrencyFormat($item["PRICE"]["RESULT_PRICE"]["BASE_PRICE"], $item["PRICE"]["RESULT_PRICE"]["CURRENCY"]);
} else {
$item["PRICE_VALUE"] = 0;
$item["PRICE_STR_VALUE"] = "";
}
}
$arItems[$item["ID"]] = $item;
}
return $arItems;
}
示例3:
$ar_iblock['LID']
))
{
$minPrice = $arOptimalPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $BASE_CURRENCY;
$minPriceRUR = CCurrencyRates::ConvertCurrency($minPrice, $BASE_CURRENCY, $RUR);
$minPriceGroup = $arOptimalPrice['PRICE']['CATALOG_GROUP_ID'];
}
}
}
else
{
if ($arPrice = CCatalogProduct::GetOptimalPrice(
$arItem['ID'],
1,
array(2), // anonymous
'N',
array(),
$ar_iblock['LID']
))
{
$minPrice = $arPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $BASE_CURRENCY;
$minPriceRUR = CCurrencyRates::ConvertCurrency($minPrice, $BASE_CURRENCY, $RUR);
$minPriceGroup = $arPrice['PRICE']['CATALOG_GROUP_ID'];
}
}
if ($minPrice <= 0) continue;
if ('' == $arItem['DETAIL_PAGE_URL'])
{
示例4: processPrice
protected function processPrice($element)
{
$element['CATALOG_DETAILS'] = \CCatalogProduct::GetOptimalPrice($element['ID']);
$element['PRICE_FORMATTED'] = $this->formatPrice($element['CATALOG_DETAILS']['PRICE']['PRICE']);
return $element;
}
示例5: elseif
$idTmp = $arSkuParentChildren[$arItems["ID"]];
$arItems["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
$arItems["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
}
if ($arItems["PREVIEW_PICTURE"] != "") {
$productImg = $arItems["PREVIEW_PICTURE"];
} elseif ($arItems["DETAIL_PICTURE"] != "") {
$productImg = $arItems["DETAIL_PICTURE"];
}
$ImgUrl = "";
if ($productImg != "") {
$arFile = CFile::GetFileArray($productImg);
$productImg = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
$ImgUrl = $productImg["src"];
}
$arPrice = CCatalogProduct::GetOptimalPrice($arItems["ID"], 1, $arBuyerGroups, "N", array(), $LID);
$arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]);
$priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
if (!is_array($arPrice["DISCOUNT"]) || count($arPrice["DISCOUNT"]) <= 0) {
$arPrice["DISCOUNT_PRICE"] = 0;
$price = $arPrice["PRICE"]["PRICE"];
} else {
$price = $arPrice["DISCOUNT_PRICE"];
}
$summaFormated = CurrencyFormatNumber($price, $arPrice["PRICE"]["CURRENCY"]);
$currentTotalPriceFormat = CurrencyFormatNumber($price, $arPrice["PRICE"]["CURRENCY"]);
$balance = 0;
$weight = 0;
if ($ar_res = CCatalogProduct::GetByID($arItems["ID"])) {
$balance = FloatVal($ar_res["QUANTITY"]);
$weight = FloatVal($ar_res["WEIGHT"]);
示例6: CatalogBasketCustomCallback
/**
* Функция обратного вызова для корзины
* аналогична функции CatalogBasketCallback за исключением использования одной определенной цены для конкретного города
*
* @param $productID
* @param $quantity
* @param $renewal
*/
function CatalogBasketCustomCallback($productID, $quantity = 0, $renewal = "N")
{
global $USER;
$productID = IntVal($productID);
$quantity = DoubleVal($quantity);
$renewal = (($renewal == "Y") ? "Y" : "N");
$arResult = array();
if ($arCatalogProduct = CCatalogProduct::GetByID($productID))
{
if ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && DoubleVal($arCatalogProduct["QUANTITY"])<=0)
return $arResult;
}
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE_DATE" => "Y",
"ACTIVE" => "Y",
"CHECK_PERMISSIONS" => "Y"
)
);
$arProduct = $dbIBlockElement->GetNext();
$arCatalog = CCatalog::GetByID($arProduct["IBLOCK_ID"]);
if ($arCatalog["SUBSCRIPTION"] == "Y")
{
$quantity = 1;
}
$rs = CPrice::GetList(
array(),
array("CATALOG_GROUP_NAME" => GetCityPrice(), "PRODUCT_ID" => $productID), false, false);
$ar = $rs -> Fetch();
$arPrice = array();
$arPrice[] = array(
"ID" => $ar["ID"],
"PRICE" => $ar["PRICE"],
"CURRENCY" => $ar["CURRENCY"],
"CATALOG_GROUP_ID" => $ar["CATALOG_GROUP_ID"]
);
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER -> GetUserGroupArray(), $renewal, $arPrice);
if (!$arPrice || count($arPrice) <= 0)
{
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $USER->GetUserGroupArray()))
{
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER->GetUserGroupArray(), $renewal);
}
}
if (!$arPrice || count($arPrice) <= 0)
{
return $arResult;
}
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
//SIGURD: logic change. see mantiss 5036.
// discount applied to a final price with VAT already included.
if ($arPrice['PRICE']['VAT_INCLUDED'] == 'N')
{
if(DoubleVal($arPrice['PRICE']['VAT_RATE']) > 0)
{
$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
$arPrice['PRICE']['VAT_INCLUDED'] = 'y';
}
}
if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0)
{
if ($arPrice["DISCOUNT"]["VALUE_TYPE"]=="F")
{
if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"])
$currentDiscount = $arPrice["DISCOUNT"]["VALUE"];
else
$currentDiscount = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT"]["VALUE"], $arPrice["DISCOUNT"]["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
else
$currentDiscount = $currentPrice * $arPrice["DISCOUNT"]["VALUE"] / 100.0;
$currentDiscount = roundEx($currentDiscount, SALE_VALUE_PRECISION);
if (DoubleVal($arPrice["DISCOUNT"]["MAX_DISCOUNT"]) > 0)
{
//.........这里部分代码省略.........
示例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: GetRecommendetProduct
/**
* Returns list of recommended products for specific product.
*
* @param int $USER_ID User id.
* @param string $LID Site id.
* @param array $arFilterRecomendet Recomendation filter.
* @param string $recomMore Get more.
* @param int $cntProductDefault Max count.
* @return array
*/
function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
{
$arRecomendetResult = array();
if (CModule::IncludeModule('catalog') && !empty($arFilterRecomendet)) {
$arRecomendet = array();
if (!is_array($arFilterRecomendet)) {
$arFilterRecomendet = array($arFilterRecomendet);
}
Main\Type\Collection::normalizeArrayValuesByInt($arFilterRecomendet);
if (empty($arFilterRecomendet)) {
return $arRecomendetResult;
}
$iblockRecommended = array();
$productIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@ID' => $arFilterRecomendet, '=ACTIVE' => 'Y')));
while ($product = $productIterator->fetch()) {
$product['ID'] = (int) $product['ID'];
$product['IBLOCK_ID'] = (int) $product['IBLOCK_ID'];
if (!isset($iblockRecommended[$product['IBLOCK_ID']])) {
$iblockRecommended[$product['IBLOCK_ID']] = array();
}
$iblockRecommended[$product['IBLOCK_ID']][] = $product['ID'];
}
unset($product, $productIterator);
if (empty($iblockRecommended)) {
return $arRecomendetResult;
}
$propertyList = array();
$propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => array_keys($iblockRecommended), '=CODE' => 'RECOMMEND', '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT)));
while ($property = $propertyIterator->fetch()) {
$property['ID'] = (int) $property['ID'];
$property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
$propertyList[$property['IBLOCK_ID']] = $property['ID'];
}
unset($property, $propertyIterator);
if (empty($propertyList)) {
return $arRecomendetResult;
}
foreach ($propertyList as $iblockID => $propertyID) {
$propertyValue = 'PROPERTY_' . $propertyID;
$filter = array('ID' => $iblockRecommended[$iblockID], 'IBLOCK_ID' => $iblockID);
$select = array('ID', 'IBLOCK_ID', $propertyValue);
$propertyValue .= '_VALUE';
$elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $select);
while ($element = $elementIterator->Fetch()) {
if (empty($element[$propertyValue])) {
continue;
}
if (is_array($element[$propertyValue])) {
foreach ($element[$propertyValue] as &$recId) {
$recId = (int) $recId;
if ($recId > 0) {
$arRecomendet[$recId] = true;
}
}
unset($recId);
} else {
$recId = (int) $element[$propertyValue];
if ($recId > 0) {
$arRecomendet[$recId] = true;
}
}
}
}
unset($element, $elementIterator, $select, $filter, $propertyValue, $propertyID, $iblockID, $propertyList);
if (!empty($arRecomendet)) {
$arRecomendet = array_keys($arRecomendet);
$arBuyerGroups = CUser::GetUserGroup($USER_ID);
$arFilter = array("ID" => $arRecomendet, "ACTIVE" => "Y");
$rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
$currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
$currentUseDiscount = CCatalogProduct::getUseDiscount();
CCatalogProduct::setUseDiscount(true);
CCatalogProduct::setPriceVatIncludeMode(true);
CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
$i = 0;
while ($arElement = $rsElement->GetNext()) {
if (in_array($arElement["ID"], $arFilterRecomendet)) {
continue;
}
if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
$arElement["MODULE"] = "catalog";
$arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
$arElement["PRODUCT_ID"] = $arElement["ID"];
$arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID, array());
$currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
$arElement["PRICE"] = $currentPrice;
$arElement["CURRENCY"] = $arPrice["RESULT_PRICE"]["CURRENCY"];
$arElement["DISCOUNT_PRICE"] = $arPrice['RESULT_PRICE']['DISCOUNT'];
if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
$arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
//.........这里部分代码省略.........
示例9: GetMEssage
$balance = " ";
$active = GetMEssage('SPS_PRODUCT_NO_ACTIVE');
$act = GetMessage("SPS_CAN_BUY_NOT_PRODUCT");
}
$row->AddField("ACT", $act);
$row->AddField("QUANTITY", $countField);
$row->AddField("BALANCE", $balance);
$row->AddField("ACTIVE", $active);
}
} else {
$fieldValue = "";
$nearestQuantity = $QUANTITY;
$arPrice = CCatalogProduct::GetOptimalPrice($arItems["ID"], $nearestQuantity, $arBuyerGroups, "N", array(), $LID, $arDiscountCoupons);
if (!$arPrice || count($arPrice) <= 0) {
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($arItems["ID"], $nearestQuantity, $arBuyerGroups)) {
$arPrice = CCatalogProduct::GetOptimalPrice($arItems["ID"], $nearestQuantity, $arBuyerGroups, "N", array(), $LID, $arDiscountCoupons);
}
}
if (!$arPrice || count($arPrice) <= 0) {
$fieldValue = " ";
} else {
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentBasePrice = $arPrice["PRICE"]["PRICE"];
if ($arPrice["PRICE"]["VAT_INCLUDED"] == "N" && DoubleVal($arPrice["PRICE"]["VAT_RATE"]) > 0) {
$currentPrice = (1 + DoubleVal($arPrice["PRICE"]["VAT_RATE"])) * $currentPrice;
}
$currentDiscount = 0.0;
if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0) {
if ($arPrice["DISCOUNT"]["VALUE_TYPE"] == "F") {
if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"]) {
$currentDiscount = $arPrice["DISCOUNT"]["VALUE"];
示例10: Add2BasketByProductID
function Add2BasketByProductID($PRODUCT_ID, $QUANTITY = 1, $arRewriteFields = array(), $arProductParams = false)
{
global $APPLICATION;
/* for old use */
if (false === $arProductParams) {
$arProductParams = $arRewriteFields;
$arRewriteFields = array();
}
$PRODUCT_ID = IntVal($PRODUCT_ID);
if ($PRODUCT_ID <= 0) {
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_EMPTY_PRODUCT_ID'), "EMPTY_PRODUCT_ID");
return false;
}
$QUANTITY = DoubleVal($QUANTITY);
if ($QUANTITY <= 0) {
$QUANTITY = 1;
}
if (!CModule::IncludeModule("sale")) {
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_NO_SALE_MODULE'), "NO_SALE_MODULE");
return false;
}
if (CModule::IncludeModule("statistic") && IntVal($_SESSION["SESS_SEARCHER_ID"]) > 0) {
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_SESS_SEARCHER'), "SESS_SEARCHER");
return false;
}
$arProduct = CCatalogProduct::GetByID($PRODUCT_ID);
if ($arProduct === false) {
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_NO_PRODUCT'), "NO_PRODUCT");
return false;
}
$CALLBACK_FUNC = "CatalogBasketCallback";
$productProviderClass = "CCatalogProductProvider";
//ADD PRODUCT TO SUBSCRIBE
if (isset($arRewriteFields["SUBSCRIBE"]) && $arRewriteFields["SUBSCRIBE"] == "Y") {
global $USER;
if ($USER->IsAuthorized() && !isset($_SESSION["NOTIFY_PRODUCT"][$USER->GetID()])) {
$_SESSION["NOTIFY_PRODUCT"][$USER->GetID()] = array();
}
$arBuyerGroups = CUser::GetUserGroup($USER->GetID());
$arPrice = CCatalogProduct::GetOptimalPrice($PRODUCT_ID, 1, $arBuyerGroups, "N", array(), SITE_ID, array());
$arCallbackPrice = array("PRICE" => $arPrice["DISCOUNT_PRICE"], "VAT_RATE" => 0, "CURRENCY" => CSaleLang::GetLangCurrency(SITE_ID), "QUANTITY" => 1);
} else {
$arRewriteFields["SUBSCRIBE"] = "N";
if ($arProduct["CAN_BUY_ZERO"] != 'Y' && $arProduct["QUANTITY_TRACE"] == "Y" && DoubleVal($arProduct["QUANTITY"]) <= 0) {
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_PRODUCT_RUN_OUT'), "PRODUCT_RUN_OUT");
return false;
}
$arCallbackPrice = CSaleBasket::ReReadPrice($CALLBACK_FUNC, "catalog", $PRODUCT_ID, $QUANTITY, "N", $productProviderClass);
if (!is_array($arCallbackPrice) || empty($arCallbackPrice)) {
$APPLICATION->ThrowException(GetMessage('CATALOG_PRODUCT_PRICE_NOT_FOUND'), "NO_PRODUCT_PRICE");
return false;
}
}
$dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $PRODUCT_ID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R"), false, false, array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL"));
$arIBlockElement = $dbIBlockElement->GetNext();
if ($arIBlockElement == false) {
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_NO_IBLOCK_ELEMENT'), "NO_IBLOCK_ELEMENT");
return false;
}
$arProps = array();
$dbIBlock = CIBlock::GetList(array(), array("ID" => $arIBlockElement["IBLOCK_ID"]));
if ($arIBlock = $dbIBlock->Fetch()) {
$arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $arIBlock["XML_ID"]);
}
$arProps[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arIBlockElement["XML_ID"]);
$arPrice = CPrice::GetByID($arCallbackPrice["PRODUCT_PRICE_ID"]);
$arFields = array("PRODUCT_ID" => $PRODUCT_ID, "PRODUCT_PRICE_ID" => $arCallbackPrice["PRODUCT_PRICE_ID"], "PRICE" => $arCallbackPrice["PRICE"], "CURRENCY" => $arCallbackPrice["CURRENCY"], "WEIGHT" => $arProduct["WEIGHT"], "QUANTITY" => $QUANTITY, "LID" => SITE_ID, "DELAY" => "N", "CAN_BUY" => "Y", "NAME" => $arIBlockElement["~NAME"], "MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "NOTES" => $arPrice["CATALOG_GROUP_NAME"], "DETAIL_PAGE_URL" => $arIBlockElement["DETAIL_PAGE_URL"], "CATALOG_XML_ID" => $arIBlock["XML_ID"], "PRODUCT_XML_ID" => $arIBlockElement["XML_ID"], "VAT_RATE" => $arCallbackPrice['VAT_RATE'], "SUBSCRIBE" => $arRewriteFields["SUBSCRIBE"]);
if ($arProduct["CAN_BUY_ZERO"] != "Y" && $arProduct["QUANTITY_TRACE"] == "Y") {
if (IntVal($arProduct["QUANTITY"]) - $QUANTITY < 0) {
$arFields["QUANTITY"] = DoubleVal($arProduct["QUANTITY"]);
}
}
if (is_array($arProductParams) && !empty($arProductParams)) {
foreach ($arProductParams as &$arOneProductParams) {
$arProps[] = array("NAME" => $arOneProductParams["NAME"], "CODE" => $arOneProductParams["CODE"], "VALUE" => $arOneProductParams["VALUE"], "SORT" => $arOneProductParams["SORT"]);
}
if (isset($arOneProductParams)) {
unset($arOneProductParams);
}
}
$arFields["PROPS"] = $arProps;
if (is_array($arRewriteFields) && !empty($arRewriteFields)) {
while (list($key, $value) = each($arRewriteFields)) {
$arFields[$key] = $value;
}
}
$addres = CSaleBasket::Add($arFields);
if ($addres) {
if (isset($arRewriteFields["SUBSCRIBE"]) && $arRewriteFields["SUBSCRIBE"] == "Y") {
$_SESSION["NOTIFY_PRODUCT"][$USER->GetID()][$PRODUCT_ID] = $PRODUCT_ID;
}
if (CModule::IncludeModule("statistic")) {
CStatistic::Set_Event("sale2basket", "catalog", $arFields["DETAIL_PAGE_URL"]);
}
}
return $addres;
}
示例11: OrderProduct
public static function OrderProduct($arParams)
{
if (!is_set($arParams, "RENEWAL") || $arParams["RENEWAL"] != "Y") {
$arParams["RENEWAL"] = "N";
}
if (!is_set($arParams, "USER_ID") || IntVal($arParams["USER_ID"]) <= 0) {
$arParams["USER_ID"] = 0;
}
if (!is_set($arParams["SITE_ID"])) {
$arParams["SITE_ID"] = false;
}
global $USER;
global $DB;
$productID = intval($arParams["PRODUCT_ID"]);
$quantity = doubleval($arParams["QUANTITY"]);
$renewal = $arParams["RENEWAL"] == "Y" ? "Y" : "N";
$strSiteID = $arParams["SITE_ID"];
$intUserID = intval($arParams["USER_ID"]);
if (0 > $intUserID) {
$intUserID = 0;
}
$arResult = array();
static $arUserCache = array();
if (0 < $intUserID) {
if (!array_key_exists($intUserID, $arUserCache)) {
$rsUsers = CUser::GetList($by = 'ID', $order = 'DESC', array("ID_EQUAL_EXACT" => $intUserID), array('FIELDS' => array('ID')));
if ($arUser = $rsUsers->Fetch()) {
$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'));
if (!($arProduct = $dbIBlockElement->GetNext())) {
return $arResult;
}
}
if ($arCatalogProduct = CCatalogProduct::GetByID($productID)) {
if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) < doubleVal($quantity))) {
return $arResult;
}
} else {
return $arResult;
}
if (0 < $intUserID) {
$arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
CCatalogDiscountSave::SetDiscountUserID($intUserID);
} else {
$arCoupons = CCatalogDiscountCoupon::GetCoupons();
}
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
if (empty($arPrice)) {
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray())) {
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
}
}
if (empty($arPrice)) {
if (0 < $intUserID) {
CCatalogDiscountSave::ClearDiscountUserID();
}
return $arResult;
}
$boolDiscountVat = 'N' != COption::GetOptionString('catalog', 'discount_vat', 'Y');
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
if ($boolDiscountVat) {
if ('N' == $arPrice['PRICE']['VAT_INCLUDED']) {
$currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
$arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
}
} else {
if ('Y' == $arPrice['PRICE']['VAT_INCLUDED']) {
$currentPrice /= 1 + $arPrice['PRICE']['VAT_RATE'];
$arPrice['PRICE']['VAT_INCLUDED'] = 'N';
}
}
$arDiscountList = array();
$arCouponList = array();
if (!empty($arPrice["DISCOUNT_LIST"])) {
$dblStartPrice = $currentPrice;
foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
//.........这里部分代码省略.........
示例12: OrderProduct
//.........这里部分代码省略.........
)
);
if ($arCatalogProduct = $rsProducts->Fetch())
{
$arCatalogProduct["QUANTITY"] = (double)$arCatalogProduct["QUANTITY"];
if ($arParams["CHECK_QUANTITY"] == "Y")
{
if (
'Y' != $arCatalogProduct["CAN_BUY_ZERO"]
&& 'Y' == $arCatalogProduct["QUANTITY_TRACE"]
&& ($arCatalogProduct["QUANTITY"] <= 0 || $quantity > $arCatalogProduct["QUANTITY"])
)
{
return $arResult;
}
}
}
else
{
return $arResult;
}
if (0 < $intUserID)
{
$arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
CCatalogDiscountSave::SetDiscountUserID($intUserID);
}
else
{
$arCoupons = CCatalogDiscountCoupon::GetCoupons();
}
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, (0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray()), $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);
if (empty($arPrice))
{
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, (0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray())))
{
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, (0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray()), $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);
}
}
if (empty($arPrice))
{
if (0 < $intUserID)
{
CCatalogDiscountSave::ClearDiscountUserID();
}
return $arResult;
}
$boolDiscountVat = ('N' != COption::GetOptionString('catalog', 'discount_vat', 'Y'));
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
if ($boolDiscountVat)
{
if ('N' == $arPrice['PRICE']['VAT_INCLUDED'])
{
$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
$arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
}
}
示例13: DoubleVal
$arSiteServers[$arAcc['LID']] = $arAcc['SERVER_NAME'];
} else {
$arAcc['SERVER_NAME'] = $arSiteServers[$arAcc['LID']];
}
$str_QUANTITY = DoubleVal($arAcc["CATALOG_QUANTITY"]);
$str_QUANTITY_TRACE = $arAcc["CATALOG_QUANTITY_TRACE"];
if ($str_QUANTITY <= 0 && $str_QUANTITY_TRACE == "Y") {
$str_AVAILABLE = ' available="false"';
} else {
$str_AVAILABLE = ' available="true"';
}
$minPrice = 0;
$minPriceRUR = 0;
$minPriceGroup = 0;
$minPriceCurrency = "";
if ($arPrice = CCatalogProduct::GetOptimalPrice($arAcc['ID'], 1, array(2), 'N', array(), $arIBlock['LID'])) {
$minPrice = $arPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $BASE_CURRENCY;
if ($BASE_CURRENCY != $RUR) {
$minPriceRUR = CCurrencyRates::ConvertCurrency($minPrice, $BASE_CURRENCY, $RUR);
} else {
$minPriceRUR = $minPrice;
}
$minPriceGroup = $arPrice['PRICE']['CATALOG_GROUP_ID'];
}
if ($minPrice <= 0) {
continue;
}
$bNoActiveGroup = True;
$strTmpOff_tmp = "";
$db_res1 = CIBlockElement::GetElementGroups($arAcc["ID"], true);
示例14: SubscribeProduct
function SubscribeProduct($intProductID, $arRewriteFields = array(), $arProductParams = array())
{
global $USER;
if (!CCatalog::IsUserExists())
return false;
if (!$USER->IsAuthorized())
return false;
$intUserID = intval($USER->GetID());
$intProductID = intval($intProductID);
if (0 >= $intProductID)
{
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_EMPTY_PRODUCT_ID'), "EMPTY_PRODUCT_ID");
return false;
}
if (!CModule::IncludeModule("sale"))
{
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_NO_SALE_MODULE'), "NO_SALE_MODULE");
return false;
}
if (CModule::IncludeModule("statistic") && array_key_exists('SESS_SEARCHER_ID', $_SESSION) && 0 < intval($_SESSION["SESS_SEARCHER_ID"]))
{
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_SESS_SEARCHER'), "SESS_SEARCHER");
return false;
}
$rsProducts = CCatalogProduct::GetList(
array(),
array('ID' => $intProductID),
false,
false,
array(
'ID',
'WEIGHT',
)
);
if (!($arCatalogProduct = $rsProducts->Fetch()))
{
$APPLICATION->ThrowException(GetMessage('CATALOG_ERR_NO_PRODUCT'), "NO_PRODUCT");
return false;
}
$rsItems = CIBlockElement::GetList(
array(),
array(
"ID" => $intProductID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSIONS" => "Y",
"MIN_PERMISSION" => "R"
),
false,
false,
array(
'ID',
'IBLOCK_ID',
'NAME',
'XML_ID',
'DETAIL_PAGE_URL'
)
);
if (!($arProduct = $rsItems->Fetch()))
return false;
$arPrice = array(
'PRICE' => 0.0,
'CURRENCY' => CSaleLang::GetLangCurrency(SITE_ID),
'VAT_RATE' => 0,
'PRODUCT_PRICE_ID' => 0,
'CATALOG_GROUP_NAME' => '',
);
$arBuyerGroups = $USER->GetUserGroupArray();
$arSubscrPrice = CCatalogProduct::GetOptimalPrice($intProductID, 1, $arBuyerGroups, "N", array(), SITE_ID, array());
if (!empty($arSubscrPrice) && is_array($arSubscrPrice))
{
$arPrice['PRICE'] = $arSubscrPrice['DISCOUNT_PRICE'];
$arPrice['CURRENCY'] = CCurrency::GetBaseCurrency();
$arPrice['VAT_RATE'] = $arSubscrPrice['PRICE']['VAT_RATE'];
$arPrice['PRODUCT_PRICE_ID'] = $arSubscrPrice["PRICE"]["ID"];
$arPrice['CATALOG_GROUP_NAME'] = $arSubscrPrice["PRICE"]["CATALOG_GROUP_NAME"];
}
$arProps = array();
$strIBlockXmlID = strval(CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID'));
if ('' != $strIBlockXmlID)
{
$arProps[] = array(
"NAME" => "Catalog XML_ID",
"CODE" => "CATALOG.XML_ID",
"VALUE" => $strIBlockXmlID
);
}
$arProps[] = array(
"NAME" => "Product XML_ID",
"CODE" => "PRODUCT.XML_ID",
//.........这里部分代码省略.........
示例15: __MakeOrder
function __MakeOrder($prdCnt = 1, $arData = array())
{
global $APPLICATION, $USER, $DB;
CModule::IncludeModule("iblock");
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
$arPrd = array();
$dbItem = CIBlockElement::GetList(array(), array("IBLOCK_TYPE" => "offers", "IBLOCK_SITE_ID" => WIZARD_SITE_ID, "PROPERTY_NEWPRODUCT" => false), false, array("nTopCount" => 100), array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL", "IBLOCK_XML_ID"));
while ($arItem = $dbItem->GetNext()) {
$arPrd[] = $arItem;
}
if (!empty($arPrd)) {
$arOrder = array("LID" => $arData["SITE_ID"], "PERSON_TYPE_ID" => $arData["PERSON_TYPE_ID"], "PAYED" => "N", "CANCELED" => "N", "STATUS_ID" => "N", "PRICE" => 1, "CURRENCY" => $arData["CURRENCY"], "USER_ID" => $arData["USER_ID"], "PAY_SYSTEM_ID" => $arData["PAY_SYSTEM_ID"]);
$fuserID = 0;
$dbFUserListTmp = CSaleUser::GetList(array("USER_ID" => $arData["USER_ID"]));
if (empty($dbFUserListTmp)) {
$arFields = array("=DATE_INSERT" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "USER_ID" => $arData["USER_ID"]);
$fuserID = CSaleUser::_Add($arFields);
} else {
$fuserID = $dbFUserListTmp['ID'];
}
$orderID = CSaleOrder::Add($arOrder);
CCatalogProduct::setPriceVatIncludeMode(true);
CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency(WIZARD_SITE_ID));
CCatalogProduct::setUseDiscount(true);
for ($i = 0; $i < $prdCnt; $i++) {
$prdID = $arPrd[mt_rand(20, 99)];
$arProduct = CCatalogProduct::GetByID($prdID["ID"]);
$arPrice = CCatalogProduct::GetOptimalPrice($prdID["ID"], 1, array(2), 'N', array(), WIZARD_SITE_ID, array());
$arFields = array("IGNORE_CALLBACK_FUNC" => "Y", "PRODUCT_ID" => $prdID["ID"], "PRODUCT_PRICE_ID" => $arPrice['PRICE']['ID'], "BASE_PRICE" => $arPrice['RESULT_PRICE']['BASE_PRICE'], "PRICE" => $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'], "VAT_RATE" => $arPrice['PRICE']['VAT_RATE'], "CURRENCY" => $arPrice['RESULT_PRICE']['CURRENCY'], "WEIGHT" => $arProduct["WEIGHT"], "DIMENSIONS" => serialize(array("WIDTH" => $arProduct["WIDTH"], "HEIGHT" => $arProduct["HEIGHT"], "LENGTH" => $arProduct["LENGTH"])), "QUANTITY" => 1, "LID" => WIZARD_SITE_ID, "DELAY" => "N", "CAN_BUY" => "Y", "NAME" => $prdID["NAME"], "CALLBACK_FUNC" => "", "MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "ORDER_CALLBACK_FUNC" => "", "CANCEL_CALLBACK_FUNC" => "", "PAY_CALLBACK_FUNC" => "", "DETAIL_PAGE_URL" => $prdID["DETAIL_PAGE_URL"], "CATALOG_XML_ID" => $prdID["IBLOCK_XML_ID"], "PRODUCT_XML_ID" => $prdID["XML_ID"], "NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "FUSER_ID" => $fuserID, "ORDER_ID" => $orderID);
$addres = CSaleBasket::Add($arFields);
}
$dbBasketItems = CSaleBasket::GetList(array(), array("ORDER_ID" => $orderID), false, false, array("ID", "QUANTITY", "PRICE"));
$ORDER_PRICE = 0;
while ($arBasketItems = $dbBasketItems->GetNext()) {
$ORDER_PRICE += roundEx($arBasketItems["PRICE"], SALE_VALUE_PRECISION) * DoubleVal($arBasketItems["QUANTITY"]);
}
$totalOrderPrice = $ORDER_PRICE + $arData["PRICE_DELIVERY"];
CSaleOrder::Update($orderID, array("PRICE" => $totalOrderPrice));
foreach ($arData["PROPS"] as $val) {
$arFields = array("ORDER_ID" => $orderID, "ORDER_PROPS_ID" => $val["ID"], "NAME" => $val["NAME"], "CODE" => $val["CODE"], "VALUE" => $val["VALUE"]);
CSaleOrderPropsValue::Add($arFields);
}
return $orderID;
}
}