Open wizyoua opened 7 years ago
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: