Page 1 of 1

Removing item from storage array (shopping cart example)

Posted: Mon May 23, 2016 3:20 pm
by Austin Troth

In the shopping cart tutorial, see link to tutorial below, I want to add a function to remove a specific item from the shopping cart. What set of commands would you use to do this, similar to the add to shopping cart. I am fairly new to appery and coding so please keep it simple. Thanks!
https://devcenter.appery.io/tutorials...


Removing item from storage array (shopping cart example)

Posted: Tue May 24, 2016 1:34 pm
by Serhii Kulibaba

Hello Austin,

Please use method splice() for that: https://developer.mozilla.org/en/docs...

e.g.:

prevar myArr = Apperyio.storage.myArr.get();
myArr = myArr.splice(1, 0);
Apperyio.storage.myArr.set(myArr);/pre
here myArr - name of your array


Removing item from storage array (shopping cart example)

Posted: Tue May 24, 2016 3:08 pm
by Austin Troth

Awesome, worked great. Thanks


Removing item from storage array (shopping cart example)

Posted: Wed Aug 09, 2017 5:19 pm
by Jason Schmidt

Sorry for the bump, but I got this to work, but it clears the entire cart, not the specific item you click


Removing item from storage array (shopping cart example)

Posted: Thu Aug 10, 2017 10:23 am
by Serhii Kulibaba

It removes the first item from the variable "myArr". If you want to remove specific item - please set it's item as a parameter of the method "splice": https://developer.mozilla.org/en/docs...