com.konakart.al
Class OrderMgr

java.lang.Object
  extended by com.konakart.al.BaseMgr
      extended by com.konakart.al.OrderMgr

public class OrderMgr
extends BaseMgr

Contains methods to manage all stages of order creation.


Field Summary
 
Fields inherited from class com.konakart.al.BaseMgr
eng, kkAppEng, log
 
Constructor Summary
protected OrderMgr(com.konakart.appif.KKEngIf eng, KKAppEng kkAppEng)
          Constructor
 
Method Summary
 void addPaymentDetailsToOrder(java.lang.String paymentCode)
          The payment details object referenced by paymentCode is added to the order.
 void addShippingQuoteToOrder(java.lang.String shippingCode)
          The shipping Quote referenced by shippingCode is added to the order.
 com.konakart.appif.OrderIf createCheckoutOrder()
          Creates a partially populated order object and sets checkoutOrder to this object.
 com.konakart.appif.OrderIf createCheckoutOrderWithOptions(com.konakart.appif.CreateOrderOptionsIf options)
          Creates a partially populated order object and sets checkoutOrder to this object.
 void createPaymentGatewayList()
          Gets an array of payment details from the engine.
 void createShippingQuotes()
          Gets an array of shipping quotes from the engine.
 void fetchAllOrders()
          It gets an array of orders sorted by date.
 com.konakart.appif.OrderIf getCheckoutOrder()
          Returns the current checkout order.
 int getCurrentOffset()
          Gets the currentOffset in the currentOrders array.
 com.konakart.appif.OrderIf[] getCurrentOrders()
          Gets an array of current orders.
 java.lang.String getHostAndPort()
          In the form servername:serverport
 int getMaxRows()
          Maximum number of orders to show in a list.
 java.lang.String getNavBack()
          navBack is a constant.
 java.lang.String getNavNext()
          navNext is a constant.
 java.lang.String getNavStart()
          navStart is a constant.
 int getNumberOfOrders()
          The number of orders in the currentOrders array.
 void getOrder(int orderId)
          It attempts to get an order from the currentOrders array.
 com.konakart.appif.PaymentDetailsIf[] getPaymentDetailsArray()
          Returns an array of payment details for the current order.
 int getPaymentType()
          Returns an int that describes the payment type of the checkoutOrder.
 com.konakart.appif.OrderIf getSelectedOrder()
          Returns the selected order.
 com.konakart.appif.ShippingQuoteIf[] getShippingQuotes()
          Gets an array of shipping quotes for the current order.
 int getShowBack()
          Show the back button if set to 1.
 int getShowNext()
          Show the next button if set to 1.
 int getTotalNumberOfOrders()
          Used to determine the total number of orders.
 boolean isUseCheckoutOrder()
          Boolean passed to GWT one page checkout code to tell it to either create a new order from the basket items or to use the current checkoutOrder as would be the case for repeat order.
 void navigateCurrentOrders(java.lang.String navDir)
          This method is called to navigate through a list of orders when the list is longer than maxRows.
 void populateCheckoutOrderWithOrderTotals()
          Calls the engine to get an array of OrderTotal objects which are added to the checkoutOrder.
 void populateCustomerOrders()
          Populates the currentCustomer object with the latest orders made.
 void refreshConfigs()
          Refresh the configuration variables.
 void repeatOrder(int orderId, boolean addToCurrentBasket, boolean copyCustomFields)
          A new Order is created with the same products as a previous order which is passed in as a parameter.
 void reset()
          Puts the OrderContainer object back into it's original state with no products selected
 int saveOrder(boolean sendEmail)
          Calls the engine to save the order.
 int saveOrder(java.lang.String hostAndPort)
          Deprecated. Since version 2.2.0.6. hostAndPort is no longer used and the sending of email cannot be controlled from this method. Use saveOrder(boolean sendEmail) instead.
 void setCheckoutOrder(com.konakart.appif.OrderIf checkoutOrder)
          Sets the checkout order with the order passed in as a parameter.
 void setCheckoutOrderBillingAddress(int addrId)
          The address object should already exist in the list of addresses for the current customer.
 void setCheckoutOrderShippingAddress(int addrId)
          The address object should already exist in the list of addresses for the current customer.
 void setHostAndPort(java.lang.String hostAndPort)
          In the form servername:serverport
 void setUseCheckoutOrder(boolean useCheckoutOrder)
          Boolean passed to GWT one page checkout code to tell it to either create a new order from the basket items or to use the current checkoutOrder as would be the case for repeat order.
 void updateInventory(int orderId)
          Update the product inventory based on the products sold in the order identified by orderId.
 
Methods inherited from class com.konakart.al.BaseMgr
getEng, getKkAppEng, setEng, setKkAppEng
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderMgr

protected OrderMgr(com.konakart.appif.KKEngIf eng,
                   KKAppEng kkAppEng)
            throws com.konakart.app.KKException
Constructor

Parameters:
eng -
kkAppEng -
Throws:
com.konakart.app.KKException
Method Detail

refreshConfigs

public void refreshConfigs()
Refresh the configuration variables. This is called automatically at a regular interval.


reset

public void reset()
           throws com.konakart.app.KKException
Puts the OrderContainer object back into it's original state with no products selected

Throws:
com.konakart.app.KKException

navigateCurrentOrders

public void navigateCurrentOrders(java.lang.String navDir)
                           throws com.konakart.app.KKException,
                                  KKAppException
This method is called to navigate through a list of orders when the list is longer than maxRows. The CurrentOrders array is updated with the new orders.
navDir can take the following values which are retrieved using getter methods on the OrderMgr instance:

Parameters:
navDir -
Throws:
com.konakart.app.KKException
KKAppException

populateCheckoutOrderWithOrderTotals

public void populateCheckoutOrderWithOrderTotals()
                                          throws com.konakart.app.KKException
Calls the engine to get an array of OrderTotal objects which are added to the checkoutOrder.

Throws:
com.konakart.app.KKException

populateCustomerOrders

public void populateCustomerOrders()
                            throws com.konakart.app.KKException
Populates the currentCustomer object with the latest orders made.

Throws:
com.konakart.app.KKException

fetchAllOrders

public void fetchAllOrders()
                    throws com.konakart.app.KKException
It gets an array of orders sorted by date. They are written to the currentOrders array.

Throws:
com.konakart.app.KKException

saveOrder

@Deprecated
public int saveOrder(java.lang.String hostAndPort)
              throws com.konakart.app.KKException,
                     KKAppException
Deprecated. Since version 2.2.0.6. hostAndPort is no longer used and the sending of email cannot be controlled from this method. Use saveOrder(boolean sendEmail) instead.

Calls the engine to save the order. The state of the order is set before saving and an email is sent if KonaKart has been configured to send emails.

Parameters:
hostAndPort - (i.e. my_server:8970)
Returns:
The id of the new order
Throws:
com.konakart.app.KKException
KKAppException

saveOrder

public int saveOrder(boolean sendEmail)
              throws com.konakart.app.KKException,
                     KKAppException
Calls the engine to save the order. The state of the order is set before saving. If KonaKart has been configured to send emails and sendEmail is set to true, an email is sent.

Parameters:
sendEmail - Set to true to send an email to the customer
Returns:
The id of the new order
Throws:
com.konakart.app.KKException
KKAppException

getOrder

public void getOrder(int orderId)
              throws com.konakart.app.KKException
It attempts to get an order from the currentOrders array. If it can't find it there, then it looks it up from the DB by making a call to the engine. The selectedOrder attribute is set to the order.

Parameters:
orderId - The id of the order to fetch.
Throws:
com.konakart.app.KKException

getNumberOfOrders

public int getNumberOfOrders()
The number of orders in the currentOrders array.

Returns:
The number of orders currently retrieved.

createCheckoutOrder

public com.konakart.appif.OrderIf createCheckoutOrder()
                                               throws com.konakart.app.KKException
Creates a partially populated order object and sets checkoutOrder to this object.

Returns:
Returns the checkoutOrder
Throws:
com.konakart.app.KKException

createCheckoutOrderWithOptions

public com.konakart.appif.OrderIf createCheckoutOrderWithOptions(com.konakart.appif.CreateOrderOptionsIf options)
                                                          throws com.konakart.app.KKException
Creates a partially populated order object and sets checkoutOrder to this object. It receives an options object as input in order to configure certain aspects of the creation.

Parameters:
options - An object containing options for the method. It may be set to null.
Returns:
Returns the checkoutOrder
Throws:
com.konakart.app.KKException

createShippingQuotes

public void createShippingQuotes()
                          throws com.konakart.app.KKException
Gets an array of shipping quotes from the engine. The quotes are put into the shippingQuotes array.

Throws:
com.konakart.app.KKException

createPaymentGatewayList

public void createPaymentGatewayList()
                              throws com.konakart.app.KKException
Gets an array of payment details from the engine. The details are put into the paymentDetails array.

Throws:
com.konakart.app.KKException

getPaymentType

public int getPaymentType()
                   throws com.konakart.app.KKException
Returns an int that describes the payment type of the checkoutOrder. Valid types are : It returns 0 if order is null or the paymentDetails object doesn't exist for the order.

Returns:
The payment type
Throws:
com.konakart.app.KKException

addShippingQuoteToOrder

public void addShippingQuoteToOrder(java.lang.String shippingCode)
The shipping Quote referenced by shippingCode is added to the order.

Parameters:
shippingCode - e.g. free, item, table, zones

addPaymentDetailsToOrder

public void addPaymentDetailsToOrder(java.lang.String paymentCode)
The payment details object referenced by paymentCode is added to the order.

Parameters:
paymentCode - The code of the payment module. e.g. cod, paypal, worldpay

setCheckoutOrderShippingAddress

public void setCheckoutOrderShippingAddress(int addrId)
                                     throws com.konakart.app.KKException
The address object should already exist in the list of addresses for the current customer. It is set as the shipping address for the current checkoutOrder.

Parameters:
addrId - The id of the address object
Throws:
com.konakart.app.KKException

setCheckoutOrderBillingAddress

public void setCheckoutOrderBillingAddress(int addrId)
The address object should already exist in the list of addresses for the current customer. It is set as the billing address for the current checkoutOrder.

Parameters:
addrId - The id of the address object

repeatOrder

public void repeatOrder(int orderId,
                        boolean addToCurrentBasket,
                        boolean copyCustomFields)
                 throws KKNotInStockException,
                        com.konakart.app.KKException,
                        KKAppException
A new Order is created with the same products as a previous order which is passed in as a parameter. The attribute CheckoutOrder is set to the new order. The same payment and shipping providers are selected although the default billing and shipping addresses are used since the original ones may no longer be valid.
All of the products are placed in the cart and a KKNotInStockException is thrown if the stock of any product is not sufficient for the order and KonaKart is configured to not allow checkout for products that are not in stock.

Parameters:
orderId - The id of the order to be repeated
addToCurrentBasket - If set to true, the order items are added to the items in the current basket. Otherwise the current basket is cleared.
copyCustomFields - If set, the custom fields of the orderProducts are copied to the custom fields of the basket items so that when the new order is created, the orderProducts of the new order have the same custom field data as the original order.
Throws:
KKNotInStockException - Thrown if the stock of any product is not sufficient for the order and KonaKart is configured to not allow checkout for products that are not in stock.
com.konakart.app.KKException
KKAppException

updateInventory

public void updateInventory(int orderId)
                     throws com.konakart.app.KKException,
                            KKAppException
Update the product inventory based on the products sold in the order identified by orderId.

Parameters:
orderId - The id of the order
Throws:
com.konakart.app.KKException
KKAppException

getCurrentOffset

public int getCurrentOffset()
Gets the currentOffset in the currentOrders array. Used to page through an array of orders.

Returns:
Returns the currentOffset in the currentOrders array

getMaxRows

public int getMaxRows()
Maximum number of orders to show in a list.

Returns:
Returns the maxRows

getShowBack

public int getShowBack()
Show the back button if set to 1. Don't show the back button if set to 0.

Returns:
Returns the showBack.

getShowNext

public int getShowNext()
Show the next button if set to 1. Don't show the next button if set to 0.

Returns:
Returns the showNext.

getNavBack

public java.lang.String getNavBack()
navBack is a constant. It is the string required to pass to the navigateCurrentOrders() as the navdir attribute when navigating backwards.

Returns:
Returns the navBack.

getNavNext

public java.lang.String getNavNext()
navNext is a constant. It is the string required to pass to the navigateCurrentOrders() as the navdir attribute when navigating forwards.

Returns:
Returns the navNext.

getNavStart

public java.lang.String getNavStart()
navStart is a constant. It is the string required to pass to the navigateCurrentOrders() as the navdir attribute when navigating to the start.

Returns:
Returns the navStart.

getSelectedOrder

public com.konakart.appif.OrderIf getSelectedOrder()
Returns the selected order.

Returns:
Returns the selectedOrder.

getTotalNumberOfOrders

public int getTotalNumberOfOrders()
Used to determine the total number of orders.

Returns:
Returns the totalNumberOfOrders.

getCurrentOrders

public com.konakart.appif.OrderIf[] getCurrentOrders()
Gets an array of current orders.

Returns:
Returns the currentOrders.

getCheckoutOrder

public com.konakart.appif.OrderIf getCheckoutOrder()
Returns the current checkout order.

Returns:
Returns the checkoutOrder.

setCheckoutOrder

public void setCheckoutOrder(com.konakart.appif.OrderIf checkoutOrder)
Sets the checkout order with the order passed in as a parameter.

Parameters:
checkoutOrder - The checkoutOrder to set.

getShippingQuotes

public com.konakart.appif.ShippingQuoteIf[] getShippingQuotes()
Gets an array of shipping quotes for the current order.

Returns:
Returns the shippingQuotes.

getPaymentDetailsArray

public com.konakart.appif.PaymentDetailsIf[] getPaymentDetailsArray()
Returns an array of payment details for the current order.

Returns:
Returns the paymentDetailsArray.

getHostAndPort

public java.lang.String getHostAndPort()
In the form servername:serverport

Returns:
Returns the hostAndPort.

setHostAndPort

public void setHostAndPort(java.lang.String hostAndPort)
In the form servername:serverport

Parameters:
hostAndPort - The hostAndPort to set.

isUseCheckoutOrder

public boolean isUseCheckoutOrder()
Boolean passed to GWT one page checkout code to tell it to either create a new order from the basket items or to use the current checkoutOrder as would be the case for repeat order.

Returns:
Returns the useCheckoutOrder.

setUseCheckoutOrder

public void setUseCheckoutOrder(boolean useCheckoutOrder)
Boolean passed to GWT one page checkout code to tell it to either create a new order from the basket items or to use the current checkoutOrder as would be the case for repeat order.

Parameters:
useCheckoutOrder - The useCheckoutOrder to set.


Copyright © 2006 DS Data Systems UK Ltd.