当前位置: 首页>>代码示例>>PHP>>正文


PHP CCatalogDiscount::GetDiscountByProduct方法代码示例

本文整理汇总了PHP中CCatalogDiscount::GetDiscountByProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscount::GetDiscountByProduct方法的具体用法?PHP CCatalogDiscount::GetDiscountByProduct怎么用?PHP CCatalogDiscount::GetDiscountByProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCatalogDiscount的用法示例。


在下文中一共展示了CCatalogDiscount::GetDiscountByProduct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 if (!empty($arResult)) {
     $arIblockId = array();
     $strImageStorePath = COption::GetOptionString("main", "upload_dir", "upload");
     $arSelect = array("ID", "NAME", "IBLOCK_SECTION_ID", "IBLOCK_TYPE_ID", "IBLOCK_ID", "DETAIL_PAGE_URL", "CATALOG_GROUP_RETAIL", "PREVIEW_PICTURE", "DETAIL_PICTURE");
     $elementIterator = CIBlockElement::GetList(array(), array("ID" => array_keys($arResult), "IBLOCK_TYPE_ID" => $arParams["IBLOCK_TYPE_ID"]), false, array(), $arSelect);
     unset($arSelect);
     while ($el = $elementIterator->GetNext()) {
         $iProductId = $arResult[$el["ID"]];
         //Если запрос не вернул цену товара, то возможно это товар с торговым предложением, поэтому получаем его базовую цену этого товара
         if ($el["CATALOG_PURCHASING_PRICE"] == "") {
             $arPrice = CPrice::GetBasePrice($iProductId);
             $el["CATALOG_PURCHASING_PRICE"] = $arPrice["PRICE"];
             $el["CATALOG_PURCHASING_CURRENCY"] = $arPrice["CURRENCY"];
         }
         //получаем скидку для товара
         $arDiscounts = CCatalogDiscount::GetDiscountByProduct($iProductId, $USER->GetUserGroupArray(), "N", 1, SITE_ID);
         //получаем цену в зависимости от скидки
         $discountPrice = false;
         if ($arDiscounts) {
             $discountPrice = CCatalogProduct::CountPriceWithDiscount($el["CATALOG_PURCHASING_PRICE"], $el["CATALOG_PURCHASING_CURRENCY"], $arDiscounts);
         }
         // путь к директории, где хранятся изображения
         $imageId = empty($el["DETAIL_PICTURE"]) ? $el["PREVIEW_PICTURE"] : $el["DETAIL_PICTURE"];
         if (!empty($imageId)) {
             /*Неэффективный кусок кода*/
             $sPath = CFile::GetByID($imageId)->GetNext();
             /**********************************/
             $sPath = "/" . $strImageStorePath . "/" . $sPath["SUBDIR"] . "/" . $sPath["FILE_NAME"];
         } else {
             $sPath = "";
         }
开发者ID:lenchv,项目名称:meblya,代码行数:31,代码来源:component.php

示例2: getBitrixDiscounts

 public function getBitrixDiscounts()
 {
     return \CCatalogDiscount::GetDiscountByProduct($this->getProduct()->id);
 }
开发者ID:AlexSmerw,项目名称:domino,代码行数:4,代码来源:CartItem.class.php

示例3: GetPriceWithDiscount

function GetPriceWithDiscount($productID, $price = 0, $arNoDis = array())
{
	$arDiscounts = CCatalogDiscount::GetDiscountByProduct(
		$productID,
		array(1,2,3,4,5,6,7,8,10,11,12,13),
		"N",
		1,
		SITE_ID
	);

	$max = 0;
	$PRIORITY = 0;
	$discompl = false;
	// PR($arDiscounts);
	
	foreach($arDiscounts as $key => $val){
		if(!in_array($val["ID"], $arNoDis))
		{	
			if($val["PRIORITY"] > $max ){
				$PRIORITY = $key;
				$max = $val["PRIORITY"];
				
				$discompl = true;
			}
		}
	}	
	if($discompl){
		if( $arDiscounts[$PRIORITY]["VALUE_TYPE"] == "P" )
			return $price - ( $price * ( $arDiscounts[$PRIORITY]["VALUE"] / 100) );
		elseif( $arDiscounts[$PRIORITY]["VALUE_TYPE"] == "F" )
			return $price - $arDiscounts[$PRIORITY]["VALUE"];
		else
			return $arDiscounts[$PRIORITY]["VALUE"];
	}else{
		return $price;
	}
}
开发者ID:akniyev,项目名称:arteva.ru,代码行数:37,代码来源:init.php

示例4: GetXMLData

 public function GetXMLData($product)
 {
     $arProp = array("ID" => GetMessage("ACRIT_PROP_ID"), "CODE" => GetMessage("ACRIT_PROP_CODE"), "NAME" => GetMessage("ACRIT_PROP_NAME"), "ACTIVE" => GetMessage("ACRIT_PROP_ACTIVE"), "DATE_CREATE" => GetMessage("ACRIT_PROP_DATE_CREATE"), "CREATED_BY" => GetMessage("ACRIT_PROP_CREATED_BY"), "DETAIL_PAGE_URL" => GetMessage("ACRIT_PROP_DETAIL_PAGE_URL"), "SHOW_COUNTER" => GetMessage("ACRIT_PROP_SHOW_COUNTER"), "QUANTITY" => GetMessage("ACRIT_PROP_QUANTITY"));
     $params = array();
     if (is_array($this->XML_DATA) && sizeof($this->XML_DATA) > 0) {
         foreach ($this->XML_DATA as $xml) {
             $tmp1 = explode("-", $xml['ID']);
             $tmp = explode("_", $tmp1[1]);
             if ($tmp[0] == "SKU") {
                 $ibl = $this->sku_IBLOCK_ID[$tmp1[0]];
                 $prop_id = $tmp[1];
                 $ph = CIBlockElement::GetProperty($ibl, $product["ID"], array("sort" => "asc"), array("ID" => $prop_id));
             } elseif ($tmp[0] == "QUANTITY") {
                 if ($this->isCat) {
                     $tr = CCatalogProduct::GetByID($product["ID"]);
                     $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($arProp[$xml["ID"]], true, true, $this->ENCODING), "CODE" => $xml["ID"], "VALUE" => $tr["QUANTITY"]);
                 }
                 $ph = false;
                 continue;
             } elseif ($tmp[0] == "PRICE") {
                 $dbProductPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $product["ID"], "CATALOG_GROUP_ID" => $tmp[1]));
                 $price = 0;
                 $names = '';
                 while ($arProductPrice = $dbProductPrices->Fetch()) {
                     if ($arProductPrice["PRICE"] && ($arProductPrice["PRICE"] < $price || !$price)) {
                         $price = $arProductPrice["PRICE"];
                     }
                     $arDissizeofs = CCatalogDiscount::GetDiscountByProduct($arProductPrice["PRODUCT_ID"], array(), "N", $arProductPrice["CATALOG_GROUP_ID"], $this->LID);
                     foreach ($arDissizeofs as $arDissizeof) {
                         if ($arDissizeof["VALUE_TYPE"] == "P") {
                             $price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"] * $arProductPrice["PRICE"] / 100;
                         } else {
                             $price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"];
                         }
                         if ($price_buf && ($price_buf < $price || !$price)) {
                             $price = $price_buf;
                         }
                     }
                     $names = $arProductPrice["CATALOG_GROUP_NAME"];
                 }
                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($names, true, true, $this->ENCODING), "CODE" => $xml["ID"], "VALUE" => $price);
                 $ph = false;
                 continue;
             } else {
                 $ibl = $tmp1[0];
                 $prop_id = $tmp1[1];
                 $mxResult = CCatalogSku::GetProductInfo($product["ID"]);
                 if (is_array($mxResult)) {
                     $ph = CIBlockElement::GetProperty($ibl, $mxResult["ID"], array("sort" => "asc"), array("ID" => $prop_id));
                 } else {
                     $ph = CIBlockElement::GetProperty($ibl, $product["ID"], array("sort" => "asc"), array("ID" => $prop_id));
                 }
             }
             if (is_object($ph)) {
                 while ($ob = $ph->GetNext()) {
                     switch ($ob["PROPERTY_TYPE"]) {
                         case "S":
                             if ($ob["USER_TYPE"] == "UserID") {
                                 $rsUser = CUser::GetByID($ob["VALUE"]);
                                 $arUser = $rsUser->Fetch();
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($arUser["LAST_NAME"] . " " . $arUser["FIRST_NAME"], true, true, $this->ENCODING));
                             } else {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
                             }
                             break;
                         case "L":
                             $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE_ENUM"], true, true, $this->ENCODING));
                             break;
                         case "E":
                             $res = CIBlockElement::GetByID($ob["VALUE"]);
                             while ($ar_res = $res->GetNext()) {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ar_res["NAME"], true, true, $this->ENCODING));
                             }
                             break;
                         case "G":
                             if ($xml['UNIT'] != "product_type") {
                                 $res = CIBlockSection::GetByID($ob["VALUE"]);
                                 while ($ar_res = $res->GetNext()) {
                                     $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ar_res["NAME"], true, true, $this->ENCODING));
                                 }
                                 break;
                             } else {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
                                 break;
                             }
                         case "F":
                             $db_file = CFile::GetByID($ob["VALUE"]);
                             while ($ar_file = $db_file->Fetch()) {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => "http://" . $this->DOMAIN_NAME . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $ar_file["SUBDIR"] . "/" . implode("/", array_map("rawurlencode", explode("/", $ar_file["FILE_NAME"]))));
                             }
                             break;
                         case "N":
                             $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
                             break;
                         default:
                             break;
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:101,代码来源:profile.php

示例5: getFinalPriceInCurrency

function getFinalPriceInCurrency($item_id, $sale_currency = 'UAH')
{
    global $USER;
    // Do item have offers?
    if (CCatalogSku::IsExistOffers($item_id)) {
        // Find price in offers
        $res = CIBlockElement::GetByID($item_id);
        if ($ar_res = $res->GetNext()) {
            if (isset($ar_res['IBLOCK_ID']) && $ar_res['IBLOCK_ID']) {
                // Find all offers
                $offers = CIBlockPriceTools::GetOffersArray(array('IBLOCK_ID' => $ar_res['IBLOCK_ID'], 'HIDE_NOT_AVAILABLE' => 'Y', 'CHECK_PERMISSIONS' => 'Y'), array($item_id), null, null, null, null, null, null, array('CURRENCY_ID' => $sale_currency), $USER->getId(), null);
                foreach ($offers as $offer) {
                    $price = CCatalogProduct::GetOptimalPrice($offer['ID'], 1, $USER->GetUserGroupArray(), 'N');
                    if (isset($price['PRICE'])) {
                        if ($price['PRICE']['CURRENCY'] != $sale_currency) {
                            $price['PRICE']['PRICE'] = CCurrencyRates::ConvertCurrency($price['PRICE']['PRICE'], $price['PRICE']['CURRENCY'], $sale_currency);
                            $price['PRICE']['CURRENCY'] = $sale_currency;
                        }
                        $price['PRICE']['PRICE_WITH_DISCOUNT'] = $price['PRICE']['PRICE'];
                        $currency_code = $price['PRICE']['CURRENCY'];
                        // Find discounts and calculate price with discounts
                        $arDiscounts = CCatalogDiscount::GetDiscountByProduct($item_id, $USER->GetUserGroupArray(), "N");
                        if (is_array($arDiscounts) && sizeof($arDiscounts) > 0) {
                            $price['PRICE']['PRICE_WITH_DISCOUNT'] = CCatalogProduct::CountPriceWithDiscount($price['PRICE']['PRICE_WITH_DISCOUNT'], $sale_currency, $arDiscounts);
                        }
                        // Stop cycle, use found value
                        break;
                    }
                }
            }
        }
    } else {
        // Simple product, not trade offers
        $price = CCatalogProduct::GetOptimalPrice($item_id, 1, $USER->GetUserGroupArray(), 'N');
        // Got price?
        if (!$price || !isset($price['PRICE'])) {
            return false;
        }
        if ($price['PRICE']['CURRENCY'] != $sale_currency) {
            $price['PRICE']['PRICE'] = CCurrencyRates::ConvertCurrency($price['PRICE']['PRICE'], $price['PRICE']['CURRENCY'], $sale_currency);
            $price['DISCOUNT_PRICE'] = CCurrencyRates::ConvertCurrency($price['DISCOUNT_PRICE'], $price['PRICE']['CURRENCY'], $sale_currency);
            $price['PRICE']['CURRENCY'] = $sale_currency;
        }
        // Change currency code if found
        if (isset($price['CURRENCY'])) {
            $currency_code = $price['CURRENCY'];
        }
        if (isset($price['PRICE']['CURRENCY'])) {
            $currency_code = $price['PRICE']['CURRENCY'];
        }
        // Get final price
        $price['PRICE']['PRICE_WITH_DISCOUNT'] = $price['DISCOUNT_PRICE'];
        // Find discounts and calculate price with discounts
        $arDiscounts = CCatalogDiscount::GetDiscountByProduct($item_id, $USER->GetUserGroupArray(), "N", 2);
        if (is_array($arDiscounts) && sizeof($arDiscounts) > 0) {
            $price['PRICE']['PRICE_WITH_DISCOUNT'] = CCatalogProduct::CountPriceWithDiscount($price['PRICE']['PRICE_WITH_DISCOUNT'], $sale_currency, $arDiscounts);
        }
    }
    // Convert to sale currency if needed
    if ($currency_code != $sale_currency) {
        $price['PRICE']['PRICE_WITH_DISCOUNT'] = CCurrencyRates::ConvertCurrency($price['PRICE']['PRICE_WITH_DISCOUNT'], $sale_currency, $sale_currency);
    }
    return $price;
}
开发者ID:VitaliiSestrenskyi,项目名称:sest,代码行数:64,代码来源:complects.php


注:本文中的CCatalogDiscount::GetDiscountByProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。