You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So in my application we are using ng-cart but I'll make a simple example to show how you can make the application more powerful:
Say you have 3 Items:
Iphone1 Iphone2 Iphone3
ng-cart has the "add to cart" button which will add say Iphone 1 to the cart
the id:of Iphone 1 lets say is id="1"
But what if the application has more options to choose like color, size, carrier. Well after passing that object into the data="{...}" attribute, we need to be able to add a unique Iphone1 to the cart so that every time you click add to cart a unique item is added to the checkout screen.
All you have to do is go into ngCart.js file - Line 213
this line grabs the initial id before even doing anything else in the program
item.prototype.setId = function(id){
if (id) this._id = id;
else {
$log.error('An ID must be provided');
}
}
In my case I wanted to simply append some number to differentiate every item that I click "add to cart" with so I did:
item.prototype.setId = function(id){
//create Unique Id here
//get millisecond var
var timestamp = new Date().getUTCMilliseconds();
//append mill var with id var to create unique id
if (id) this._id = id + timestamp;
else {
$log.error('An ID must be provided');
}
};
Now you can go and add a item to the cart, click checkout and check console. You will see the id of that item be appended with 3 more numbers.
Current Thoughts on this:
I think this is a good work around since if you need to add more of the same kind you can just click the + in the check out screen
One thing that happens is even if you have the same item + same data it will still be a unique iditem so in the checkout screen you will keep adding a new item everytime, Which may work for you or not.
The text was updated successfully, but these errors were encountered:
wizyoua
changed the title
How to add multiple Items of the same ID
How to add multiple Items of the same core product ID
Dec 9, 2016
if you have iphone 1 with options e. g. size of memory 32, 64, 128 or with colors green, red, blue. You can make id for ngCart by adding them to id, Example: If you have id="1" for your iphone id can be id+size+color and it will be 132red. It will be unique and repeatable if user will try to add again.
So in my application we are using ng-cart but I'll make a simple example to show how you can make the application more powerful:
Say you have 3 Items:
Iphone1 Iphone2 Iphone3
ng-cart has the "add to cart" button which will add say Iphone 1 to the cart
the id:of Iphone 1 lets say is id="1"
But what if the application has more options to choose like color, size, carrier. Well after passing that object into the data="{...}" attribute, we need to be able to add a unique Iphone1 to the cart so that every time you click add to cart a unique item is added to the checkout screen.
All you have to do is go into ngCart.js file - Line 213
this line grabs the initial id before even doing anything else in the program
In my case I wanted to simply append some number to differentiate every item that I click "add to cart" with so I did:
Now you can go and add a item to the cart, click checkout and check console. You will see the id of that item be appended with 3 more numbers.
Current Thoughts on this:
The text was updated successfully, but these errors were encountered: