13 Replies Latest reply: Sep 21, 2012 12:52 AM by 333 RSS

    Order Object Creation

    333
      hi all,

      How the order Object is created when the session starts(On Browser Open)
      and when the handleCreate method in the OrderHolder is being called.



      thanks and regards
      shya
        • 1. Re: Order Object Creation
          karthik chopperla
          When you first add an item to order, SHoppingCart($class is OrderHolder) component's current property is checked if user has any order, if it doesnt, it asks OrderManager to create an Order.

          OrderManager create the initialOrder by building OrderImpl object from OrderTools, CommerceItem from CommerceItemManager, similarly creates Empty Shipping Group, Empty payment group, creates ItemPriceInfo and adds it to commerceItem and then CommerceItem is added to Order object.

          -karthik
          • 2. Re: Order Object Creation
            333
            hi karthik, thanks for your reply

            as per the concept when we open a (index) page itself order object is created. how its being created when the session starts,
            • 3. Re: Order Object Creation
              karthik chopperla
              ShoppingCart is a session based component. So with session establishment, the component is created and its properties such as last placed order, saved order are populated based on profile's auto login property (cookie).

              If there is no autologin, user is just anonymous coming to site for the first time, then those are empty and they get populated when you add an item to cart.

              -karthik
              • 4. Re: Order Object Creation
                333
                hi karthik, sorry yaar , i think your misunderstood the query.

                my question is-- for anonymous user order object is created, how it will be created ?
                • 5. Re: Order Object Creation
                  karthik chopperla
                  It is created when you access ShoppingCart.current property. This property is accessed only when you add an item to the order through your CartModifierFormHandler.

                  SO answer to your question is when you add an item to the cart.

                  -karthik
                  • 6. Re: Order Object Creation
                    enzo_rio
                    @karthik,

                    When you try to access this ShoppingCart.current in a JSP page, the order is created, It calls the handle create method in OrderHolder class. You need not add item to cart to create an order.

                    Just try printing the ShoppingCart.current in your index.jsp , Order is created without commerce items.

                    I think thats what "shy" was asking for.

                    Correct me if i am wrong.

                    Regards

                    SK
                    • 7. Re: Order Object Creation
                      333
                      hi Enzo rio,


                      When the Session starts, Order object is created with empty shipping group and payment group. My question is how that order object is created????
                      Is the HandleCreate method in the OrderHolder class will be called.when the session start????.

                      Regards,
                      Shy
                      • 8. Re: Order Object Creation
                        Nitin Khare
                        When you access ShoppingCart.current then OrderHolder creates the Order if it is not already there by calling createInitialOrder(). And OrderHolder's createInitialOrder() internally invokes OrderManager's createOrder() to create the Order object.
                        • 9. Re: Order Object Creation
                          enzo_rio
                          @shya

                          My question is how that order object is created????

                          When you access the ShoppingCart.current in your jsp page. Handle create method in the OrderHolder class is called. From the

                          OrderHolder.handleCreate ->OrderHolder.createInitailOrder-->OrderManager.createOrder (These are the methods that get called when you access Shopping.current in your jsp, which will create a Order Object for the current profile profile).

                          Is the HandleCreate method in the OrderHolder class will be called.when the session start????.

                          Its not when the session starts, its when you access the ShoppingCart.current . (There are different ways an order is created) one of the way is when u access ShoppingCart.current, CartmodifierFormhandler.additemtoOrder etc etc..

                          See understand whats ur doubt exactly. Like how profile is getting created when session starts, you want to know how order is getting created right.

                          Profile is created in the DAF request pipeline in ProfileRequestServlet , but order does not get created in request pipeline. but it gets created in may ways, like i mentioned above.
                          For example:
                          U have only index.jsp in your atg project in which profile is displayed. until and unless you use or access shoppingcart.current order is not created.
                          <dsp:valueof bean="/atg/commerece/Shoppingcar.current"/>

                          when you use the above code to print order, it calls the handle create. hope i cleared your doubt

                          Regards
                          -Sumanth Kethe
                          • 10. Re: Order Object Creation
                            karthik chopperla
                            Sumanth,

                            You are right about Order creation, you need not add item to cart to actually create an order. The very call to SHoppingCart.current creates it.

                            But the likely scenario of one calling that method is when adding item to the cart. Even if you call by directly going to cart page, the cart would be empty. You would not really call ShoppingCart.current on productDetail, main page e.t.c unless you have a mini cart in main page.

                            -karthik
                            • 11. Re: Order Object Creation
                              333
                              hi sumanth,

                              is that any other way to create order object, except ShoppingCart.current, and CartModifierFormHandler.AddItemtoOrder



                              regards
                              shya
                              • 12. Re: Order Object Creation
                                enzo_rio
                                @shya.

                                What is your doubt exactly.??? How order get created or when order gets created.???


                                See the OrderManager class, it has createorder method which takes different set of parameters.
                                Example:

                                createOrder(String pProfileId)


                                createOrder(String pProfileId, String pOrderType)


                                createOrder(String pProfileId, String pOrderId, String pOrderType)


                                createOrder(String pProfileId, OrderPriceInfo pOrderPriceInfo, TaxPriceInfo pTaxPriceInfo, ShippingPriceInfo pShippingPriceInfo)


                                createOrder(String pProfileId, OrderPriceInfo pOrderPriceInfo, TaxPriceInfo pTaxPriceInfo, ShippingPriceInfo pShippingPriceInfo, String pOrderType)


                                createOrder(String pProfileId, String pOrderId, OrderPriceInfo pOrderPriceInfo, TaxPriceInfo pTaxPriceInfo, ShippingPriceInfo pShippingPriceInfo, String pOrderType)


                                You need to go through the Oracle-ATG doc. It will help you. If you still have doubts you can get back.

                                Regards
                                -SK
                                • 13. Re: Order Object Creation
                                  333
                                  hi, sumanth

                                  you have mentioned in the past post like

                                  (There are different ways an order is created) one of the way is when u access ShoppingCart.current, CartmodifierFormhandler.additemtoOrder etc etc..

                                  is there any other way to create an order object like which u mentioned above,

                                  i didnt asked the create order overloaded methods


                                  regards
                                  shya