Coder Social home page Coder Social logo

tonyvu2014 / android-shoppingcart Goto Github PK

View Code? Open in Web Editor NEW
87.0 87.0 70.0 909 KB

An implementation of android shopping cart library project for Android

License: MIT License

Java 100.00%
android android-shoppingcart ecommerce shopping-cart

android-shoppingcart's People

Contributors

friederbluemle avatar tonyvu2014 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-shoppingcart's Issues

Image

How can I add images to the product? Please provide source code.

Store cart in array, and then...

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?

How to add same product twice with different attributes

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

Firebase Realtime

Hello ... I liked the library, how could I implement it to Firebase ???

Adding image to each item

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!

Final Request for Help

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.

Out of memory error

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.