tonyvu2014 / android-shoppingcart Goto Github PK
View Code? Open in Web Editor NEWAn implementation of android shopping cart library project for Android
License: MIT License
An implementation of android shopping cart library project for Android
License: MIT License
Hi, sorry to bother you once again, however, this is the final thing I need help with in terms of fully implementing your Shopping Cart system within my app. Maybe you can give me advice, or point me in the right direction. (I apologise if this is not the correct place to do this). I am essentially trying to create a "Re-Order" system; meaning that after the user places an order, then the system will store that order in either an online database or in a session on the device. So, if the user clicks the "Re-Order" button, their cart will be updated with the items which they previously had ordered.
Currently, I have the system set up to email me the order when the user places the order, and store the string in the database. However, I am not certain as how to approach updating the shopping cart with the corresponding items of that order. I'm thinking I need to create a separate table for orders, but I am not sure how to update the shopping cart with the order info (for example, if I order 3 items, I would store those items in a database on 3 separate rows of Item Name, Quantity, and Unit Price. Then I would need to pull that data from the database, and populate the shopping cart with said data).
Any help will be greatly appreciated.
Hello @tonyvu2014 , i just integrated your library with my project and yes it's really cool , i enjoyed the code and the way you manage the whole process , but as per my requirement , i am just trying to add same product in my cart list having different attribute but is unable to add , i tried alot but it seems i am confused with your one condition can you please help me to understand the point , What i simply want to do is , suppose i am having one product on my screen having multiple color and sizes , so at first i add the product to my cart with color Blue and size XS and now i am trying to add same product with Color Black and Size S or Color Blue but this time having Size M , your library do not let me to add same product twice , can you please tell me that what should i do to achieve this As this is very basic feature for every shoping cart.
Here is my code :-
`public void add(final Saleable sellable, int quantity) {
if (cartItemMap.containsKey(sellable)) {
mConfigSelectedObject = sellable.getConfigurableselectedArray();
Cart cartget = CartHelper.getCart();
List<CartItem> cartlist = getCartItems(cartget);
if (mConfigSelectedObject.length() > 0) {
if (isEqualArray(cartlist, mConfigSelectedObject)) {
cartItemMap.put(sellable, cartItemMap.get(sellable)
+ quantity);
} else {
cartItemMap.put(sellable, quantity);
}
} else {
cartItemMap.put(sellable, cartItemMap.get(sellable) + quantity);
}
} else {
cartItemMap.put(sellable, quantity);
}
configurableparamArray = sellable.getConfig();
totalPrice = totalPrice.add(sellable.getPrice().multiply(
BigDecimal.valueOf(quantity)));
totalQuantity += quantity;
}
private boolean isEqualArray(List<CartItem> cartlist,
JSONArray mConfigSelectedObject2) {
boolean isEqual = false;
for (int i = 0; i < cartlist.size(); i++) {
for (int j = 0; j < cartlist.get(i).getProduct()
.getConfigurableselectedArray().length(); j++) {
try {
if (cartlist
.get(i)
.getProduct()
.getConfigurableselectedArray()
.getJSONObject(j)
.getString(Constants.KEY_ATTRIBUTE_ID)
.equalsIgnoreCase(
mConfigSelectedObject2.getJSONObject(j)
.getString(
Constants.KEY_ATTRIBUTE_ID))
&& cartlist
.get(i)
.getProduct()
.getConfigurableselectedArray()
.getJSONObject(j)
.getString(Constants.KEY_OPTION_ID)
.equalsIgnoreCase(
mConfigSelectedObject2
.getJSONObject(j)
.getString(
Constants.KEY_OPTION_ID))) {
isEqual = true;
} else {
isEqual = false;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
mConfigSelectedObject = new JSONArray();
return isEqual;
}`
As you are the master of this library , so it will be easy for you to tell me what should i do with cartItemMap.containsKey(sellable)
Thanks
Hey...I sometimes get an out of memory error in ProductActivity class on the following line:
ivProductImage.setImageResource(this.getResources().getIdentifier(product.getImageName(), "drawable", this.getPackageName()));
it happens when i click a product on the main activity list view.
how i can add a new item in cart ej: color selection ?
^
Is it possible to delete individual items from shopping cart?
Is there a way to store the existing shopping cart items in an array or variable, clear the actual shopping cart, and then place those items stored in the array/variable, back in the cart after clicking a button? Maybe via the use of a session variable?
Hi, is it possible to add an image onto each product in the product list, and/or shopping cart? If so, can you let me know how to? Thank you very much!
i want to use products from firebase database, how do i set them up in ProductAdapter using this library
Hello ... I liked the library, how could I implement it to Firebase ???
How can I add images to the product? Please provide source code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.