Skip to content

Cart Sample #3

Description

@kdesineedi

Hi Paolo/Savs,

Can you guys kindly help me in knowing what is wrong with the below code?

<%
session.addCartEntry(baseProduct,1);
List<CommerceSession.CartEntry> list = session.getCartEntries();
out.println("Size::::"+list.size());
Iterator<CommerceSession.CartEntry> itr = list.iterator();

       while(itr.hasNext()) {
           Product p=(Product)itr.next().getProduct();
    out.println("in loop----"+p);

}

output:
out.println("Size::::"+list.size()); --> Prints the size of the cart based on the addition of items as expected

However
out.println("in loop----"+p); is always null.

Can you please let me know how to get this product from the cart ?

Kindly note that all my other objects(session,baseProduct,list are non-null) and addCart method works fine.

I could not find a comments section so posting it here.Sorry for that.
-K

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions