Answer the question
In order to leave comments, you need to log in
Discount for each item in the cart. It seems that he did everything, but the final amount is not the same, what is the mistake?
Hello!
I made a free discount in the basket for goods, everything is fine, but when we go to the page, it shows the correct amount:
And when we add the quantity, for example, on the screen of the second product, the amount becomes one product:
I can’t understand what the problem is, somewhere else js I need to edit, maybe someone did something similar, tell me, please.
In the code, if you remove in the array:
Then the final amount is considered normal, but without the necessary product discounts.
In the mutator.php file, I made changes to the discounts at the top:
in foreach
$result['allSum'] += $row['SUM_VALUE'];
$go3sale = "";
$intElementID = 100; // ID предложения
$mxResult = CCatalogSku::GetProductInfo($row['PRODUCT_ID']);
$pid = 0;
if (is_array($mxResult))
{
$pid = $mxResult['ID'];
}
else
{
$pid = $row['PRODUCT_ID'];
}
$iteratorz = CIBlockElement::GetPropertyValues(21, array("ID"=>$pid));
while ($arFields = $iteratorz->Fetch())
{
//var_dump($arFields[198]);
if($arFields[198] != "")
{
$go3sale = "";
for($i=0;$i<=count($arFields[198]);$i++)
{
if($arFields[198][$i] == "7892"){ $go3sale = "ok";}
}
}
}
if ($go3sale == "ok"){$allskidos=$com2;}else{$allskidos=$com1;}
//Скидка
$row['DISCOUNT_PRICE'] = $row['PRICE'] * $allskidos / 100;
$row['PRICE'] = $row['PRICE'] - $row['DISCOUNT_PRICE'];
if ($allskidos > 0)
$row['DISCOUNT_PRICE_PERCENT'] = $allskidos;
$row['SUM_VALUE'] = $row['PRICE'] * $row['QUANTITY'];
$result['allSum'] += $row['SUM_VALUE'];
$row['SUM_DISCOUNT_PRICE'] = $row['DISCOUNT_PRICE'] * $row['QUANTITY'];
$row['PRICE_FORMATED'] = CCurrencyLang::CurrencyFormat($row['PRICE'], $row['CURRENCY'], true);
$row['SUM'] = CCurrencyLang::CurrencyFormat($row['SUM_VALUE'], $row['CURRENCY'], true);
$row['DISCOUNT_PRICE_FORMATED'] = CCurrencyLang::CurrencyFormat($row['DISCOUNT_PRICE'], $row['CURRENCY'], true);
$row['SUM_DISCOUNT_PRICE_FORMATED'] = CCurrencyLang::CurrencyFormat($row['SUM_DISCOUNT_PRICE'], $row['CURRENCY'], true);
if ($allskidos > 0)
$row['DISCOUNT_PRICE_PERCENT_FORMATED'] = $allskidos.'%';
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question