Shopping cart + Storage + add and remove quantity for specific item in ionic 3
up vote
0
down vote
favorite
I am working on this shopping cart module for one of my projects and this is the first time I am working on feature lie Shopping cart. Here I have a button for every item and once I click on one item I want to display the + and - buttons in order to increase/decrease the quantity for that specific item.
Now what is happening in my scenario is I am able to display buttons for all items u I am failing to add a specific item, it adds all the items and if i go to remove it doesn't do anything (It reflects all items), and quantity for that item needs to be stored/removed/updated locally. Here is my code snippets.
my .ts file
addQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter += counter;
console.log(this.storageValue[key].count);
return;
}
this.counter = this.counter+1;
this.quantities.push(quantity[key]);
console.log(this.quantities.push(quantity[key]));
}
}
subQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter--;
console.log(this.storageValue[key].counter--);
if(this.storageValue[key]){
}
break;
}
console.log(this.storageValue[key].counter--);
}
}
}
my html file
<ion-content>
<ion-icon name="add-circle" (click)="addQuantity(displayItems.ITEMID)" item-right></ion-icon>
{{counter}}
<ion-icon name="remove-circle"(click)="subQuantity(displayItems.ITEMID)" item-right></ion-icon>
</div>
<div *ngIf="!alive">
<button ion-button item-end (click)="alive = !alive">Add</button>
</div>
<!-- Customisable -->
</div>
</ion-item>
I am a beginner and learning Ionic. Your guidance will be appreciated.
ionic3 shopping-cart ionic-storage
add a comment |
up vote
0
down vote
favorite
I am working on this shopping cart module for one of my projects and this is the first time I am working on feature lie Shopping cart. Here I have a button for every item and once I click on one item I want to display the + and - buttons in order to increase/decrease the quantity for that specific item.
Now what is happening in my scenario is I am able to display buttons for all items u I am failing to add a specific item, it adds all the items and if i go to remove it doesn't do anything (It reflects all items), and quantity for that item needs to be stored/removed/updated locally. Here is my code snippets.
my .ts file
addQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter += counter;
console.log(this.storageValue[key].count);
return;
}
this.counter = this.counter+1;
this.quantities.push(quantity[key]);
console.log(this.quantities.push(quantity[key]));
}
}
subQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter--;
console.log(this.storageValue[key].counter--);
if(this.storageValue[key]){
}
break;
}
console.log(this.storageValue[key].counter--);
}
}
}
my html file
<ion-content>
<ion-icon name="add-circle" (click)="addQuantity(displayItems.ITEMID)" item-right></ion-icon>
{{counter}}
<ion-icon name="remove-circle"(click)="subQuantity(displayItems.ITEMID)" item-right></ion-icon>
</div>
<div *ngIf="!alive">
<button ion-button item-end (click)="alive = !alive">Add</button>
</div>
<!-- Customisable -->
</div>
</ion-item>
I am a beginner and learning Ionic. Your guidance will be appreciated.
ionic3 shopping-cart ionic-storage
1
Could you show whatthis.storageValue
looks like ?
– saperlipopette
Nov 22 at 8:32
its just storageValue:number;
– shashank verma
Nov 22 at 9:43
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on this shopping cart module for one of my projects and this is the first time I am working on feature lie Shopping cart. Here I have a button for every item and once I click on one item I want to display the + and - buttons in order to increase/decrease the quantity for that specific item.
Now what is happening in my scenario is I am able to display buttons for all items u I am failing to add a specific item, it adds all the items and if i go to remove it doesn't do anything (It reflects all items), and quantity for that item needs to be stored/removed/updated locally. Here is my code snippets.
my .ts file
addQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter += counter;
console.log(this.storageValue[key].count);
return;
}
this.counter = this.counter+1;
this.quantities.push(quantity[key]);
console.log(this.quantities.push(quantity[key]));
}
}
subQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter--;
console.log(this.storageValue[key].counter--);
if(this.storageValue[key]){
}
break;
}
console.log(this.storageValue[key].counter--);
}
}
}
my html file
<ion-content>
<ion-icon name="add-circle" (click)="addQuantity(displayItems.ITEMID)" item-right></ion-icon>
{{counter}}
<ion-icon name="remove-circle"(click)="subQuantity(displayItems.ITEMID)" item-right></ion-icon>
</div>
<div *ngIf="!alive">
<button ion-button item-end (click)="alive = !alive">Add</button>
</div>
<!-- Customisable -->
</div>
</ion-item>
I am a beginner and learning Ionic. Your guidance will be appreciated.
ionic3 shopping-cart ionic-storage
I am working on this shopping cart module for one of my projects and this is the first time I am working on feature lie Shopping cart. Here I have a button for every item and once I click on one item I want to display the + and - buttons in order to increase/decrease the quantity for that specific item.
Now what is happening in my scenario is I am able to display buttons for all items u I am failing to add a specific item, it adds all the items and if i go to remove it doesn't do anything (It reflects all items), and quantity for that item needs to be stored/removed/updated locally. Here is my code snippets.
my .ts file
addQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter += counter;
console.log(this.storageValue[key].count);
return;
}
this.counter = this.counter+1;
this.quantities.push(quantity[key]);
console.log(this.quantities.push(quantity[key]));
}
}
subQuantity(quantity,counter){
for (var key in this.storageValue){
if(this.storageValue[key] === quantity){
this.storageValue[key].counter--;
console.log(this.storageValue[key].counter--);
if(this.storageValue[key]){
}
break;
}
console.log(this.storageValue[key].counter--);
}
}
}
my html file
<ion-content>
<ion-icon name="add-circle" (click)="addQuantity(displayItems.ITEMID)" item-right></ion-icon>
{{counter}}
<ion-icon name="remove-circle"(click)="subQuantity(displayItems.ITEMID)" item-right></ion-icon>
</div>
<div *ngIf="!alive">
<button ion-button item-end (click)="alive = !alive">Add</button>
</div>
<!-- Customisable -->
</div>
</ion-item>
I am a beginner and learning Ionic. Your guidance will be appreciated.
ionic3 shopping-cart ionic-storage
ionic3 shopping-cart ionic-storage
edited Nov 22 at 7:37
asked Nov 22 at 4:33
shashank verma
96
96
1
Could you show whatthis.storageValue
looks like ?
– saperlipopette
Nov 22 at 8:32
its just storageValue:number;
– shashank verma
Nov 22 at 9:43
add a comment |
1
Could you show whatthis.storageValue
looks like ?
– saperlipopette
Nov 22 at 8:32
its just storageValue:number;
– shashank verma
Nov 22 at 9:43
1
1
Could you show what
this.storageValue
looks like ?– saperlipopette
Nov 22 at 8:32
Could you show what
this.storageValue
looks like ?– saperlipopette
Nov 22 at 8:32
its just storageValue:number;
– shashank verma
Nov 22 at 9:43
its just storageValue:number;
– shashank verma
Nov 22 at 9:43
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423941%2fshopping-cart-storage-add-and-remove-quantity-for-specific-item-in-ionic-3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Could you show what
this.storageValue
looks like ?– saperlipopette
Nov 22 at 8:32
its just storageValue:number;
– shashank verma
Nov 22 at 9:43