A
A
Alexander2019-12-27 01:24:11
1C-Bitrix
Alexander, 2019-12-27 01:24:11

How to display the cost of goods in the initial quantity?

5e05312012cca707652899.png
At Bitrix, the price is displayed on the detailed page (examples in the picture). It can be taking into account the coefficient of addition to the basket, it can be per kilogram, or maybe even 0.7 kilos. Picture 1 and 3 immediately after loading, the user did not click anything. Because the price may not be per kilo, you need to display it like in pictures 2 and 4 so that the phrase "for the amount of XXX rubles." was immediately, when loading the page in the picture 1 and 3. i.e. when the user has not started to increase the amount. I can output stupidly in PHP, but I need this line to go away when I increase it, and this is in JS, I can’t find anything in the script file. I ask the collective wisdom for help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PetrPo, 2020-12-30
@kikher

Example with catalog.element standard template bootstrap_v4 file script.js
function setPrice: function() at the very end there is a verification
change to (for TP this will be enough) For simple goods, add your own function, something like

initPriceTotal: function() {
  if(this.obPrice && this.obQuantity) {
    this.obQuantity.value = this.stepQuantity;
    this.setPrice();
  }
},

in the init: function() function you are looking for the if (this.productType === 3) check after it you add
else {
  this.initPriceTotal();
}

Can you add php to the template so that js does not jerk when loading

A
Andrey Savrasov, 2019-12-27
@alcorn

The quantity change handling is in the script.js of the catalog.item component.
Insert your code there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question