KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: MikaRinne1970 on September 28, 2012, 08:58:38 am

Title: A question about creating order programmatically
Post by: MikaRinne1970 on September 28, 2012, 08:58:38 am
Hi

I'm customly populating the order from the basket but somehow I don't think I get the shipping cost populated correctly

I'm doing this:
// Attach the shipping quote to the order
kkAppEng.getOrderMgr().addShippingQuoteToOrder("quoteflat");

(Flat shipping configured via admin)

// Populate the checkout order with order totals
kkAppEng.getOrderMgr().populateCheckoutOrderWithOrderTotals();   

Am I missing something ?

Many thanks in advance,
Mika

Title: Re: A question about creating order programmatically
Post by: MikaRinne1970 on September 28, 2012, 02:00:15 pm
If you are doing about the same and it's working, I'd be happy to know about it.
If you are doing something different, please infom.

Thanks again
Mika
Title: Re: A question about creating order programmatically
Post by: ryan on September 28, 2012, 07:46:32 pm
I suggest you either look at the struts action classes where we create an order or you follow the example (InsertOrder.java) which you can find under KonaKart\java_api_examples\src\com\konakart\apiexamples .
Title: Re: A question about creating order programmatically
Post by: MikaRinne1970 on September 29, 2012, 02:50:03 pm
Thanks for the pointer! I will look into it!

Many thanks
Title: Re: A question about creating order programmatically
Post by: MikaRinne1970 on September 30, 2012, 10:07:34 am
I got it working!

I checked CheckoutDeliveryAction and realised that I have to create the shipping quotes before inserting one into the check out order:

// Get shipping quotes from the engine
                kkAppEng.getOrderMgr().createShippingQuotes();

                // Get shipping quotes for the order and choose the first one in the list for this order
                ShippingQuoteIf[] sQuotes = kkAppEng.getOrderMgr().getShippingQuotes();
                if (sQuotes != null && sQuotes.length > 0)
                {
                   checkoutOrder.setShippingQuote(sQuotes[0]);
                   System.out.println("shipping = " + sQuotes[0]);
                }
               
                // Populate the checkout order with order totals
                kkAppEng.getOrderMgr().populateCheckoutOrderWithOrderTotals();     

Many thanks!

Konakart is kewl  8)