Data Store Quantity Showing Null

I followed @Teodor’s tutorial here to create a Shopping Cart.

The shopping cart adds the product correctly, but the quantity field is not showing any data. I checked and double checked to make sure that the quantity + 1 was entered correctly and reviewed various posts, but I can not seem to get this to work correctly.

Here is the data store:

Here is the button action (upsert):

Here is the code view of the button:

Screenshot 2024-03-01 at 7.14.41 AM

Here is the result:

Screenshot 2024-03-01 at 7.15.00 AM

Here is the Chrome Developers view of the local session storage:

This must be the decimal field… Considered as a string by JS.


Add .toNumber() and I think you will be OK

1 Like

Hi @famousmag! Thanks for the assistance!

I tried doing the convert to number with and without the backticks, but I am getting NAN in the modal and still null in the session storage.

Screenshot 2024-03-01 at 7.37.56 AM

image
the actual code please

In addition to doing the data store conversion to number recommended above, I tried with it being the original quantity

and then with the conversion to a number.

does quantity have a default value, eg 1?
quantity.defalut(1)
looks like there is no value for it there…

I can try adding that, but would not the button that opens the modal be setting the initial value through the upsert?

Just tried setting the default to 1 and there was no change. :frowning:

I see quotes in your button upsert action…
Ypu must have missed that my friend
delete the quotes… (Make sure that ONLY quantity turns blue)

No those are backticks and @Teodor is very specific that they have to include the quantity and the plus 1.

Screenshot 2024-03-01 at 8.05.40 AM

However I did try the following:

quantity + 1
'quantity' + 1
'quantity + 1'
`quantity` + 1
`quantity + 1` (which is the one indicated to use)
"quantity" + 1
"quantity + 1"

Just checked a old site where I did this.

`quantity+1` works so maybe a bug?

Are you sure that is just quantity?
Bind from the ui for sure…

I’m confused, you guys are talking about quantity+1, but that’s to increase the quantity by clicking the button.

Before you increase the quantity (before you click the button), is the quantity shown?

There’s no point talking about quantity+1 if the problem comes before…

How is the product being added? Have you double-checked the quantity is being set?

1 Like

Yes, the product has been added, but the quantity has not.

This is the section where it seems to stop for me.

It’s an upsert step, so that it `quantity+1` should add 1 if no quantity is set.
We’ve fixed that for App Connect 2 so you can get the latest file from here:

dmxAppConnect.zip (28.6 KB)

This will be included in the next update, most probably early next week.

2 Likes

Interesting, alternatively I’m guessing it should work with quantity.default(0)+1

1 Like

Thanks @Teodor for the quick fix!

Appreciate @famousmag, @Hyperbytes, and @Apple for the assist!

1 Like

Fixed in Wappler 6.3.2

This topic was automatically closed after 26 hours. New replies are no longer allowed.