Introducntion
------------------
OrderItemAddCmdImpl and OrderItemUpdateCmdImpl extends the OrderItemBaseCmdImpl command which contains the logic for add/update to the cart
Please refer the commands which are called in below sequence
---------------------------
1)ResolveSkuCmdImpl
2)OrderCreateCmd
3)ResolveOrderItemPriceCmd
4)GetContractUnitPriceCmd
5)UpdateShippingAddressCmd
6)ValidateOrderAddressCmd
7)--ValidateTradingPaymentCmd
8)DoInventoryActionCmd
9)UpdateShipInfoCmdImpl
10)RaiseOrderEventCmdImpl
11)OrderCalculateCmd
12)ExtendedOrderItemProcessCmd
Please refer below the main methods used in the flow-
orderItemAdd(i)
---------------
ResolveSkuCmd -> Finds the type of catalog entry. If it is a package then PackageResolveSkuCmd is called. If it is a product then this command determines the attributes required to resolve the product to an orderable item.
OrderCreateCmd -> Creates the blank order
CheckCatalogEntryEntitlementCmd -> Checks if customer is entitlement to buy this catentry id
updateOrder()
-------------
Update Orders table record for ShipAsComplete,Decriptiopn and Comment
updatePrice()
-------------
ResolveOrderItemPriceCmd -> calculates the best price and update order total which in turn calls the GetContractUnitPriceCmd
updateAddressId()
-----------------
UpdateShippingAddressCmd -> calls findAddressIdForOrderItem() to find the shipping address for orderitem, validateShippingAddress() to validate address
ValidateOrderAddressCmd -> validates billingaddress and shipping address
updateShippingAddress() -> updates the shipping address
updateShipModeId()
------------------
Updates store default shipmode based upon storedef table
validateTradingPaymentMethods()
------------------------------
validates that the payment method is compatible with the trading agreement
updateFulfillmentCenter()
-------------------------
If doInventory = Y,DoInventoryActionCmd -> Takes action based upon the store inventory system
updateAddressIdForBOPIS()
----------------------
Calls UpdateShippingAddressCmd for BOPIS items
prepareShipInfo()
----------------
PrepareShipInfoCmd
updateShippingInstructions()
---------------------------
UpdateShipInfoCmd -> updates the shipping instructions, shipping account number and shipping charge type
updateShippingAccountNumber()
updateShippingChargeType()
raiseBusinessEvents()
---------------------
RaiseOrderEventCmd -> raises ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT
calculateOrder()
----------------
OrderCalculateCmd- calculations based on the calUsageIds passed in
For all the new items:
1)ResolveOrderItemPriceCmd is called to calculate the best price and update order total
2)We can supply the parameter doPrice to ResolveOrderItemPriceCmd command to control whether the OrderItems can skip pricing again
3)UpdateShippingAddressCmd command is called to update shipping address
4)Update the shipping mode
5)ValidateTradingPaymentCmd command is called to validate that the payment method is compatible with the trading agreement
6) If we have doInventory set as Y, then we call DoInventoryActionCmd to update the fulfillment centers and available inventory check
7)UpdateShipInfoCmd command is called to update the shipping instructions, shipping account number and shipping charge type
8)RaiseOrderEventCmd command is called to raise the ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT
9)If the flag calculateOrder is set then OrderCalculateCmd command is called to do calculations that are based on the calUsageIds passed in.
10)ExtendOrderItemProcessCmd command is called to execute any customization logic added.
Sequence of Activities from Front-end in REST based flow
1) ProductDisplay.jsPDP page add to cart button invokes the JS call-
productDisplayJS.Add2ShopCartAjax()
which in turn invokes the AddItem2ShopCartAjax() method in the productdisplay.js-
productDisplayJS.AddItem2ShopCartAjax(catalogEntryId , quantity,customParams, productId);
It invokes the server call-
wc.service.invoke(ajaxShopCartService, params); where Where ajaxShopCartService = "AddOrderItem";
2) ShoppingActionsServicesDeclaration.js
It defines the server call as below-
wc.service.declare({
id: "AddOrderItem",
actionId: "AddOrderItem",
url: getAbsoluteURL() + "AjaxRESTOrderItemAdd",
formId: ""
3) struts-config-order-rest-services.xml
The service call("AjaxRESTOrderItemAdd") is defined as below in struts-config-order-rest-services.xml file-
<action parameter="orderlist.addOrderItem" path="/AjaxRESTOrderItemAdd" type="com.ibm.commerce.struts.AjaxRESTAction">
<set-property property="authenticate" value="0:0"/>
<set-property property="https" value="0:1"/>
</action>
4) rest-template-config.xml
The "orderList" is defined in rest-template-config.xml of order module as follow-
<resource path="{serverHost}/wcs/resources/store/{storeId}/cart" name="orderlist"> and the method is defined as below-
<method name="addOrderItem" httpMethod="POST" path="">
<template>
<![CDATA[{
"orderId" : "$orderId",
"orderItem" : [
{
"comment" : "$comment",
"productId" : "$catEntryId",
"partNumber" : "$partNumber",
"quantity" : "$quantity",
"UOM" : "$UOM",
"contractId" : "$contractId",
"calculationUsage" : "$calculationUsage",
"fulfillmentCenterId" : "$fulfillmentCenterId",
"fulfillmentCenterName" : "$fulfillmentCenterName"
}
],
"x_calculationUsage" : "$calculationUsage",
"x_calculateOrder" : "$calculateOrder",
"x_inventoryValidation" : "$inventoryValidation"
}]]>
</template>
</method>
Input parameters will be set in the above name-value pair. Now the resource path will be taken from the declaration and the handler will be invoked-
<resource path="{serverHost}/wcs/resources/store/{storeId}/cart" name="orderlist"> which leads to com.ibm.commerce.rest.order.handler.CartHandler
5) CartHandler
OOB com.ibm.commerce.rest.order.handler.CartHandler has the method addOrderItem() which initiates the inbound change order service invocation using ChangeOrderSOIBODMapping.xmlf entry.
P:S- rest-cart-clientobjects.xml is used to map the response properties with userdata field section being used as a base to map custom response paramaters.
------------------
OrderItemAddCmdImpl and OrderItemUpdateCmdImpl extends the OrderItemBaseCmdImpl command which contains the logic for add/update to the cart
Please refer the commands which are called in below sequence
---------------------------
1)ResolveSkuCmdImpl
2)OrderCreateCmd
3)ResolveOrderItemPriceCmd
4)GetContractUnitPriceCmd
5)UpdateShippingAddressCmd
6)ValidateOrderAddressCmd
7)--ValidateTradingPaymentCmd
8)DoInventoryActionCmd
9)UpdateShipInfoCmdImpl
10)RaiseOrderEventCmdImpl
11)OrderCalculateCmd
12)ExtendedOrderItemProcessCmd
Please refer below the main methods used in the flow-
orderItemAdd(i)
---------------
ResolveSkuCmd -> Finds the type of catalog entry. If it is a package then PackageResolveSkuCmd is called. If it is a product then this command determines the attributes required to resolve the product to an orderable item.
OrderCreateCmd -> Creates the blank order
CheckCatalogEntryEntitlementCmd -> Checks if customer is entitlement to buy this catentry id
updateOrder()
-------------
Update Orders table record for ShipAsComplete,Decriptiopn and Comment
updatePrice()
-------------
ResolveOrderItemPriceCmd -> calculates the best price and update order total which in turn calls the GetContractUnitPriceCmd
updateAddressId()
-----------------
UpdateShippingAddressCmd -> calls findAddressIdForOrderItem() to find the shipping address for orderitem, validateShippingAddress() to validate address
ValidateOrderAddressCmd -> validates billingaddress and shipping address
updateShippingAddress() -> updates the shipping address
updateShipModeId()
------------------
Updates store default shipmode based upon storedef table
validateTradingPaymentMethods()
------------------------------
validates that the payment method is compatible with the trading agreement
updateFulfillmentCenter()
-------------------------
If doInventory = Y,DoInventoryActionCmd -> Takes action based upon the store inventory system
updateAddressIdForBOPIS()
----------------------
Calls UpdateShippingAddressCmd for BOPIS items
prepareShipInfo()
----------------
PrepareShipInfoCmd
updateShippingInstructions()
---------------------------
UpdateShipInfoCmd -> updates the shipping instructions, shipping account number and shipping charge type
updateShippingAccountNumber()
updateShippingChargeType()
raiseBusinessEvents()
---------------------
RaiseOrderEventCmd -> raises ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT
calculateOrder()
----------------
OrderCalculateCmd- calculations based on the calUsageIds passed in
For all the new items:
1)ResolveOrderItemPriceCmd is called to calculate the best price and update order total
2)We can supply the parameter doPrice to ResolveOrderItemPriceCmd command to control whether the OrderItems can skip pricing again
3)UpdateShippingAddressCmd command is called to update shipping address
4)Update the shipping mode
5)ValidateTradingPaymentCmd command is called to validate that the payment method is compatible with the trading agreement
6) If we have doInventory set as Y, then we call DoInventoryActionCmd to update the fulfillment centers and available inventory check
7)UpdateShipInfoCmd command is called to update the shipping instructions, shipping account number and shipping charge type
8)RaiseOrderEventCmd command is called to raise the ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT
9)If the flag calculateOrder is set then OrderCalculateCmd command is called to do calculations that are based on the calUsageIds passed in.
10)ExtendOrderItemProcessCmd command is called to execute any customization logic added.
Sequence of Activities from Front-end in REST based flow
1) ProductDisplay.jsPDP page add to cart button invokes the JS call-
productDisplayJS.Add2ShopCartAjax()
which in turn invokes the AddItem2ShopCartAjax() method in the productdisplay.js-
productDisplayJS.AddItem2ShopCartAjax(catalogEntryId , quantity,customParams, productId);
It invokes the server call-
wc.service.invoke(ajaxShopCartService, params); where Where ajaxShopCartService = "AddOrderItem";
2) ShoppingActionsServicesDeclaration.js
It defines the server call as below-
wc.service.declare({
id: "AddOrderItem",
actionId: "AddOrderItem",
url: getAbsoluteURL() + "AjaxRESTOrderItemAdd",
formId: ""
3) struts-config-order-rest-services.xml
The service call("AjaxRESTOrderItemAdd") is defined as below in struts-config-order-rest-services.xml file-
<action parameter="orderlist.addOrderItem" path="/AjaxRESTOrderItemAdd" type="com.ibm.commerce.struts.AjaxRESTAction">
<set-property property="authenticate" value="0:0"/>
<set-property property="https" value="0:1"/>
</action>
4) rest-template-config.xml
The "orderList" is defined in rest-template-config.xml of order module as follow-
<resource path="{serverHost}/wcs/resources/store/{storeId}/cart" name="orderlist"> and the method is defined as below-
<method name="addOrderItem" httpMethod="POST" path="">
<template>
<![CDATA[{
"orderId" : "$orderId",
"orderItem" : [
{
"comment" : "$comment",
"productId" : "$catEntryId",
"partNumber" : "$partNumber",
"quantity" : "$quantity",
"UOM" : "$UOM",
"contractId" : "$contractId",
"calculationUsage" : "$calculationUsage",
"fulfillmentCenterId" : "$fulfillmentCenterId",
"fulfillmentCenterName" : "$fulfillmentCenterName"
}
],
"x_calculationUsage" : "$calculationUsage",
"x_calculateOrder" : "$calculateOrder",
"x_inventoryValidation" : "$inventoryValidation"
}]]>
</template>
</method>
Input parameters will be set in the above name-value pair. Now the resource path will be taken from the declaration and the handler will be invoked-
<resource path="{serverHost}/wcs/resources/store/{storeId}/cart" name="orderlist"> which leads to com.ibm.commerce.rest.order.handler.CartHandler
5) CartHandler
OOB com.ibm.commerce.rest.order.handler.CartHandler has the method addOrderItem() which initiates the inbound change order service invocation using ChangeOrderSOIBODMapping.xmlf entry.
P:S- rest-cart-clientobjects.xml is used to map the response properties with userdata field section being used as a base to map custom response paramaters.
No comments:
Post a Comment