P
P
pavelmosin2019-06-19 18:44:35
1C-Bitrix
pavelmosin, 2019-06-19 18:44:35

Bitrix. How to change the price of an item in the cart to your own?

Good afternoon.
There is a product, a calculator for choosing additional options is written on the detailed card.
When buying, accordingly, the cost of options is not applied, but remains basic.
How can I change the base price to the price that was calculated on the detailed one?
I watched this guide , method 3. But I didn’t understand where to insert this code?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Savrasov, 2019-06-20
@alcorn

Instruction is correct
In init.php
1. Inherit your Provider

class CCatalogProductProviderCustom extends CCatalogProductProvider
{
  public static function GetProductData($arParams)
  {
                   //Чтобы не переписывать всю логику наследуемся от родителя
                   $arResult = parent::GetProductData($arParams);
                   
                  //Ниже описываем свою логику подменяем данные в  $arResult
                 return $arResult;
        }
}

2. We also declare our price handler in init.php. Those. own class "CCatalogProductProviderCustom"
AddEventHandler('sale', 'OnSaleBasketItemRefreshData', 'BeforeBasketAddHandler');
function BeforeBasketAddHandler($BasketItem)
{
  $BasketItem->setField("PRODUCT_PROVIDER_CLASS", "CCatalogProductProviderCustom");
}

3. Remove all items from the cart and add a new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question