Z
Z
zahar_922020-11-09 20:11:25
1C-Bitrix
zahar_92, 2020-11-09 20:11:25

How to convert product price in cart in mutator.php?

Hello!
Why is the cart price conversion that happens in mutator.php not visible in script.js? I do currency conversion in mutator

$result['BASKET_ITEM_RENDER_DATA'] = array();
foreach ($this->basketItems as $row)
{
    $rowData = array(
        'ID' => $row['ID'],
        'PRODUCT_ID' => $row['PRODUCT_ID'],
        'NAME' => isset($row['~NAME']) ? $row['~NAME'] : $row['NAME'],
        'FULL_PRICE' => $row['FULL_PRICE'],
);
$rowData["FULL_PRICE"] =  CCurrencyRates::ConvertCurrency($rowData["FULL_PRICE"], 'RUB', "USD");
$result['BASKET_ITEM_RENDER_DATA'][] = $rowData;
}

Next, in the basket template, I display the value from the array. It's available and I can get it. But when updating the quantity of goods in the cart, the amount is recalculated by ajax. I opened script.js and outputted everything contained in res.BASKET_DATA to the console, and so there is BASKET_ITEM_RENDER_DATA, but it contains the default values, and not changed by me.

1. Why does BASKET_ITEM_RENDER_DATA in script.js contain unchanged values?
2. How can I change them according to the metator principle?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question