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

How can I add a coupon code to an order using the SOAP APIs?

Started by diyhs, November 26, 2009, 12:54:54 am

Previous topic - Next topic

diyhs

I am using the WS API of Konakart 4.1 to implement a check-out feature for a companion site for my store.

From my companion site, I am instantiating a KKWSEngIf object using:
KKWSEngIf kkEng = new KKWSEngIfServiceLocator().getKKWebServiceEng();

Using the kkEng object, I create an order using the createOrder method, passing Basket items that had been selected.  This all works beautifully.  I am also able to use the order.getOrderTotals() method to display the shipping and taxes calculated for these items (which was the whole purpose for using the shopping cart from Konakart in the companion site to begin with!).

My problem is that now that I have all of this information (the basket items, the order totals, shipping, etc), I am displaying it to the end-user and providing them with a "coupon" field to receive discounts.  That is all good, except that when I then try to apply that coupon (which has been associated in the Konakart store with a promotion that applies to these products), I can't seem to find any method within the WS API to be able to apply it to an existing order! 

I have tried to find ways around this by not doing the createOrder() method until after I have the coupon, but that doesn't work very well from a usability perspective, since I need to show them what they are ordering and how much it costs prior to getting the coupon information.

And once the createOrder is called, the order is in the order DB of the store and can't seem to be modified except for a limited set of attributes (none of which are the couponCode).  I guess an option would be to delete the previous order and create a new one with the coupon code, but this seems to be a lot of service call thrashing!

Does anyone have any suggestions?

BTW, on a somewhat related note, the javadoc for createOrder implies it doesn't save the order to the database until the saveOrder method is called.  However, this is not the case and the db is populated with the order after the createOrder method.  The saveOrder method seems to have no function whatsoever...


vpod

You just need to put the cupon code in the order and later save it:

KKWSEngIf eng = new KKWSEngIfServiceLocator().getKKWebServiceEng();
Basket[] basketItems = eng.getBasketItemsPerCustomer(sessionId,-1,-1);

Order order = eng.createOrder(sessionId,basketItems,-1);

String cupon = "QWERTY";
order.setCouponCode(cupon);

[...]

orderId = eng.saveOrder(sessionId, order, -1);


Ther order is not saved in the database until you save it. Unless you use the createAndSaveOrder method.

Quote from: diyhs on November 26, 2009, 12:54:54 am
I am using the WS API of Konakart 4.1 to implement a check-out feature for a companion site for my store.

From my companion site, I am instantiating a KKWSEngIf object using:
KKWSEngIf kkEng = new KKWSEngIfServiceLocator().getKKWebServiceEng();

Using the kkEng object, I create an order using the createOrder method, passing Basket items that had been selected.  This all works beautifully.  I am also able to use the order.getOrderTotals() method to display the shipping and taxes calculated for these items (which was the whole purpose for using the shopping cart from Konakart in the companion site to begin with!).

My problem is that now that I have all of this information (the basket items, the order totals, shipping, etc), I am displaying it to the end-user and providing them with a "coupon" field to receive discounts.  That is all good, except that when I then try to apply that coupon (which has been associated in the Konakart store with a promotion that applies to these products), I can't seem to find any method within the WS API to be able to apply it to an existing order! 

I have tried to find ways around this by not doing the createOrder() method until after I have the coupon, but that doesn't work very well from a usability perspective, since I need to show them what they are ordering and how much it costs prior to getting the coupon information.

And once the createOrder is called, the order is in the order DB of the store and can't seem to be modified except for a limited set of attributes (none of which are the couponCode).  I guess an option would be to delete the previous order and create a new one with the coupon code, but this seems to be a lot of service call thrashing!

Does anyone have any suggestions?

BTW, on a somewhat related note, the javadoc for createOrder implies it doesn't save the order to the database until the saveOrder method is called.  However, this is not the case and the db is populated with the order after the createOrder method.  The saveOrder method seems to have no function whatsoever...