global $USER;
$objUser=new CUser;
$rsUserFields = $objUser->GetList(($by="personal_country"), ($order="desc"), Array('ID'=>$USER->GetID()),array('SELECT'=>Array('UF_*')));
$arUserFields = $rsUserFields->Fetch();
if (CModule::IncludeModule("catalog"))
{
echo $arUserFields['UF_SUM_ORDER'];
CCatalogDiscount::SetCoupon('CP-FIK3S-YWVIXQR');
if ((int)$arUserFields['UF_SUM_ORDER'] >= 50000)
{
CCatalogDiscount::SetCoupon('CP-BTDYV-6E0YTNY');
$objUser->Update($USER->GetID(), array('UF_STATUS'=>'Silver'));
}
if ((int)$arUserFields['UF_SUM_ORDER'] >= 100000)
{
CCatalogDiscount::SetCoupon('CP-RCMM1-OWQQR12OWQQR12');
$objUser->Update($USER->GetID(), array('UF_STATUS'=>'Gold'));
}
if ((int)$arUserFields['UF_SUM_ORDER'] >= 150000)
{
CCatalogDiscount::SetCoupon('CP-IAR8P-WMRTB8H');
$objUser->Update($USER->GetID(), array('UF_STATUS'=>'Platinum'));
}
if ((int)$arUserFields['UF_SUM_ORDER'] >= 250000)
{
CCatalogDiscount::SetCoupon('CP-LWJHQ-TY9UB46');
$objUser->Update($USER->GetID(), array('UF_STATUS'=>'VIP'));
}
};
|