Urgent Problem with data store

Hoping someone can help with this today.

I have a datastore where I want to add the button for the +1 qty
I have currently in the update have quantity + 1 however this is not increasing the qty is is only adding quantity +1 in the qty cell on the table and does not increase the qty

Heres a link to the page http://club.thegunnery.online/Admin-Add-Order
Any ideas?

Your expression is wrong. You wrapped it in single quotes, so it’s considered a string. Everything wrapped in single quotes is a string.
It should look like:

{quantity: `quantity + 1`}

and NOT

{quantity: '`quantity + 1`'}
2 Likes

That is amazing you are replying to questions early in the morning on Easter Monday @Teodor!
Wishing you a happy holiday day! :slightly_smiling_face:

1 Like

Happy Easter, Antony!

I’m living in Bulgaria, where Easter this year is a bit later than the catholic one - on May 2nd :slight_smile: The orthodox church here says so! :slight_smile:

1 Like

Oh wow…
Well in that case, Happy Not Easter Monday!

2 Likes

This is a copy from the code page @teodor and I’m still having the same issue

dmx-on:click="ordered_items.update({ssc: ssc},{quantity: '`quantity + 1`'})

Thanks for answering on a weekend as well buddy. This is why I love this community.

Did you check my reply above?

Not sure what happened the first time, it was making it 1 (hit add gave) 11
but now it seems to be working ok.
thanks very much @Teodor

ok not sure what is going on but in the table it is now adding the one as 1 (after add button shows) 11
Also in the table the repeated button for another product the button does not work.

Before it updated all qty’s to the amount it changed to.
Really not sure what I am doing wrong here buddy.

Heres a link http://club.thegunnery.online/Admin-Add-Order

Please make sure to clear your data store from the browser dev tools, as it probably caches old data:

OK got the numbers going up and down, but if you add 2 products it changes both numbers and not the line the button is on.
also the second buttons do not work.

Wrong expression in your table …

 <td dmx-text="ordered_items.data[0].quantity"></td>

must be

 <td dmx-text="quantity"></td>

Also in the update data store dynamic event don’t filter by ssc but by ID.

All of this is pretty well explained in the docs already.

And the issue is that you are using an input as a value for the quantity on insiert in data store.
Input values are always strings, so 1 is added as string, you should convert it to number so that the update action can see it properly and sum the quantity:

dmx-on:click="ordered_items.insert({quantity: inp_ds_qty.value.toNumber(), description: inp_ds_description.value, ssc: inp_ds_ssc.value, rrp: inp_ds_rrp.value.toNumber().formatCurrency('$', '.', ',', 2)})"><i
                                    class="fa fa-plus-square"></i></button>
1 Like

Thats awesome, all the problems are sorted out. I did not realise you had to add the .toNumber when the field was number.
All working thanks very much for your help.
As normal impeccable support from you guys :slight_smile:

1 Like