Variable increment

Hey guys!

How would you increment a variable on the front end in a repeater?
I have a variable named total_price that I would like to increment with the price of each article in the repeat. I would prefer not using the DB query for that:

<div class="row" is="dmx-repeat" id="repeat1" dmx-bind:repeat="dt_booking.data.products">
    <div class="row">
        <div class="col w-75">{{name}}</div>
        <div class="col w-75">{{quantity}} jour(s)</div>
        <div class="col text-end">{{price.formatCurrency('€', '.', ',', 2)}}</div>
        <div class="col text-end">
            <button id="btn_delete_booking_product" class="btn btn-sm" dmx-on:click="dt_booking_product.select(id)" data-bs-toggle="modal" data-bs-target="#modal_delete_product"><i class="far fa-trash-alt"></i></button>

            {{ something like: total_price += price }}
            
        </div>
    </div>
</div>

Thank you!

Do you want to sum the price property for each of the repeat items?

And multiplied by the quantity (the price of the current item multiplied by the quantity of the current item)

Multiply is ok {{ price * quantity }}

The idea is to just print the total after listing the products

yes product1 + products2 etc and at the end {{ total_price }}

Your expression should be located outside of the repeat. There's a sum formatter available, which you can use:

{{repeat1.items.sum(`price`)}}
1 Like

I knew Teodor was going to miss the quantity multiplication :laughing:

Throwing ideas, I'd probably use something like a Page Flow and use a Repeat step, but I'm not very experienced on the front-end

1 Like

Perfect! Thank you