AddEventHandler("iblock", "OnAfterIBlockElementUpdate", Array("MyClass2", "OnAfterIBlockElementUpdateHandler"));
class MyClass2
{
// создаем обработчик события "OnAfterIBlockElementUpdate"
function OnAfterIBlockElementUpdateHandler(&$arFields)
{
if (intval($arFields["IBLOCK_ID"]) == 49)
{
if (CModule::IncludeModule("catalog")
&& CCatalog::GetByID($arFields["IBLOCK_ID"]) && CModule::IncludeModule("iblock") && CModule::IncludeModule("sale"))
{
$db_props = CIBlockElement::GetProperty(49, intval($arFields["ID"]), array("sort" => "asc"), Array("CODE"=>"DISCOUNT"));
if($ar_props = $db_props->Fetch())
$DISCOUNT = intval($ar_props["VALUE"]);
$db_res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => intval($arFields["ID"]),
"CATALOG_GROUP_ID" => 9,
)
);
if ($ar_res2 = $db_res->Fetch())
{
$price=intval($ar_res2["PRICE"]);
}
$price_new=$price-$price*$DISCOUNT/100;
|