Help with a complex expression in a client side formatter

This is what I am trying to do

On the left we have list of extras, each has a price and a quantity. If the quantity is greater than 0 it adds it to the right hand side, if the quantity is more than 1 it multiplies the price by the quantity.

There is also a base price of the accommodation shown at the top right in this case 185

I now want to show the order total, and have it update as the user enters quantities on the left.

As you can see on the bottom right i have a total showing 185154.25 so basically my formatter has concatenated the 2 prices together instead of adding them to each other to give a total of 339.25

this is how the 185 part is calculated

sc_site_layout_checker_selected_room.data.query_selected_room.prices.where(`wvrsp_year`, sc_site_layout_checker.data.query_this_wedding.wvw_wedding_date.formatDate('yyyy'), '==').values('wvrsp_price')

As each year has a different price it needs to get the correct pricing based upon when the wedding is being held, which could easily be 2 years from now, this part works great.

The second part 154.25 also works perfectly with this

scf_room_booking_payment.repeat_room_detail_extras.items.where(`inp_wve_description.value`, 1, '>=').sum(`inp_wve_description_price.value*inp_wve_description.value`)

This calculates all xtra quantity prices where the quantity is greater than 0, and then sums the price multiplied by the quantity. As I mentioned this is calculating perfectly too.

This is when the problem comes in, adding the result of expression 1 with expression 2, i have tried. few ways, but none of them are working, however this one makes the most sense to me

((sc_site_layout_checker_selected_room.data.query_selected_room.prices.where(`wvrsp_year`, sc_site_layout_checker.data.query_this_wedding.wvw_wedding_date.formatDate('yyyy'), '==').values('wvrsp_price'))+(scf_room_booking_payment.repeat_room_detail_extras.items.where(`inp_wve_description.value`, 1, '>=').sum(`inp_wve_description_price.value*inp_wve_description.value`)))

However as you can see in the screenshot, that concatenates my 2 prices instead of adding them together. If I try fix it using the Wappler formatter i get the following error.

And I am getting no console log error.

Anyone got any ideas.

Community Page
Last updated: