SOLVED: Item pricing inquiry.

Hello all.

I just want to ask if there’s a way on having an automatic pricing conversion (simply as math?, like excel?). Attached herewith screenshot of sample.

Pricing column (number) (multiple by) Conversion column (number) and result (total) will be using as the price of the item.

Hope for a much clearer information than giving the link of another forum.
Thank you in advance.

Hi,
You can use data hooks to calculate the multiplication of the conversion & price:

export function myCollection_afterQuery(item, context) { 
   item.price *= item.conversion;
   return item; 
}

Click here to get more information about this hook.

Best,
Tal.

Hi Ms. Tal,

Thank you for your reply, really appreciates it.
Sorry for a non-coder like me, it’s so hard for me to understand the code.

I used hooks and it add column price but not added conversion ( i made collection for a test).
It somehow gives me a lead on my plan but how it will calculate like a simply multiplication?

Also i want to put it on a text box, so text box will be the number answer (price * conversion = text box)

or is there a way that i can put one column with number field (ex: 100), then a simple code without using input field. (collection column*0.05 = text box). I think repeater connected on a collection can automatic tag the result based on id.

Hope you get my point.

Thank you

Hi Ms. Tal,

Im so happy to say that i found my answer. The code like this
i made 2 column and tag the columns made by the made.
item.price (item.rates * item.conversionrate)
item.total = item.price

Then on my repeater i used a text box and connect to data (total).
Question, how to remove the decimals or to round up numbers?

Thank you for the help