Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddEventHandler("catalog", "OnGetOptimalPrice", 'OnGetOptimalPriceHandler');
- function OnGetOptimalPriceHandler($productID,$quantity){
- if ( CModule::IncludeModule("catalog") && CModule::IncludeModule("iblock") ){
- $ar_res = CCatalogProduct::GetByID($productID);
- if ( $quantity > 0 ){
- $priceId = "1";
- $keyPrice = "CATALOG_PRICE_1";
- $code = "BASE";
- }else{
- $priceId = "2";
- $keyPrice = "CATALOG_PRICE_2";
- $code = "PREDZAKAZ_PRICE";
- }
- #$discount_arr = CCatalogDiscount::GetByID($productID);
- $obj_el = CIBlockElement::GetList( array(),
- array("ID"=>$productID,"IBLOCK_ID"=>"2"),
- false,
- false,
- array("ID","IBLOCK_ID","CATALOG_GROUP_".$priceId)
- );
- if ( $element = $obj_el->GetNext()){
- #echo "<pre>"; print_r ($ar_res); echo "</pre>";
- return array(
- 'PRICE' => array(
- 'ID' => $priceId,
- 'CATALOG_GROUP_ID' => $code,
- 'PRICE' => $element[$keyPrice],
- 'CURRENCY' => "RUB",
- 'ELEMENT_IBLOCK_ID' => $element["ID"],
- 'VAT_RATE' => $ar_res["VAT_ID"],
- 'VAT_INCLUDED' => $ar_res["VAT_INCLUDED"]
- ),
- 'DISCOUNT_PRICE' => '12208',
- 'DISCOUNT'=>array(
- 'VALUE'=> '5',
- 'VALUE_TYPE'=>'P',
- 'ID' => '2',
- 'CURRENCY'=>'RUB',
- 'SITE_ID'=>SITE_ID,
- 'ACTIVE'=>'Y',
- 'RENEWAL'=>'N',
- 'ACTIVE_FROM' => '',
- 'ACTIVE_TO' => '',
- 'MAX_DISCOUNT' =>'0',
- 'COUPON' => '',
- 'COUPON_ONE_TIME' => '',
- 'COUPON_ACTIVE' => '',
- "SORT"=>"500"
- )
- );
- }
- }
- }
Add Comment
Please, Sign In to add comment