• Welcome to KonaKart Community Forum. Please login or sign up.
 

A question about creating order programmatically

Started by MikaRinne1970, September 28, 2012, 08:58:38 am

Previous topic - Next topic

MikaRinne1970

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


MikaRinne1970

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

ryan

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 .

MikaRinne1970

Thanks for the pointer! I will look into it!

Many thanks

MikaRinne1970

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)