Orderwave

Orderwave is a software application that can automate many processes of an online ordering application or shopping cart. It can do order retrieval, data validation, inventory allocation, data delivery, and payment processing and capturing. It can act as a gateway between a warehouse, shipping, and your commerce shopping application. Orderwave passes data between the client cart and Orderwave system through XML. Some of the XML methods that they have are addorder, getinventory, getshipupdate, getorderstatus, getcatalog, and getcarrierrejects. For the application I was coding, I only needed to used the addorder method.

First, I had to build the list of order items in a variable through a loop.

<cfset linedata = “”>

<cfset numitems = 0>

<cfloop query=”Cart”>

<cfset numitems = numitems + 1>

<cfset linedata = linedata & ” <line_item>

<item_number>#Cart.SKU_MERCHSKUID#</item_number>

<inventory_number>#Cart.SKU_MERCHSKUID#</inventory_number>

<item_description>#Cart.product_Name#</item_description>

<item_price>#Replace(NumberFormat(Cart.SKU_Price,’999999999.99′),” “,”",”ALL”)#</item_price>

<item_quantity>#Cart.cart_sku_qty#</item_quantity> <extended_item_price>#Replace(NumberFormat(Cart.SKU_Price*Cart.cart_sku_qty,’999999999.99′),” “,”",”ALL”)#</extended_item_price>

</line_item>

“>

</cfloop>

Then, I had to build the addorder XML method in a variable then post it through https to Orderwave’s server.

<cfoutput>

<cfsavecontent variable=”strXML”><?xml version=”1.0″ encoding=”utf-8″ ?>

<orderwave>

<call>addorder</call>

<version>1.0.8</version>

<username>#Replace(Replace(orderwavelogin, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</username>

<password>#Replace(Replace(orderwavepass, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</password>

<call_values>

<order_number>#Replace(Replace(Client.CartID, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</order_number>

<order_status>active</order_status>

<order_date>#Year(now())#-#month(now())#-#Day(now())#</order_date>

<email>#Replace(Replace(CustBilling.cst_Email, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</email>

<ship_method>#Replace(Replace(getMethodName.shipmeth_OName, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_method>

<ship_instructions>none</ship_instructions>

<partial_shipment>0</partial_shipment>

<gift_order>0</gift_order>

<order_source>website</order_source>

<bill_to>

<bill_firstname>#Replace(Replace(CustBilling.cst_FirstName, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_firstname>

<bill_lastname>#Replace(Replace(CustBilling.cst_LastName, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_lastname>

<bill_address1>#Replace(Replace(CustBilling.cst_Address1, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_address1>

<bill_address2>#Replace(Replace(CustBilling.cst_Address2, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_address2>

<bill_city>#Replace(Replace(CustBilling.cst_City, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_city>

<bill_state>#Replace(Replace(CustBilling.stprv_Name, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_state>

<bill_zip>#Replace(Replace(CustBilling.cst_Zip, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_zip>

<bill_country>#Replace(Replace(CustBilling.country_Code, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_country>

<bill_phone>#Replace(Replace(CustBilling.cst_Phone, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</bill_phone>

</bill_to>

<ship_to>

<ship_firstname>#Replace(Replace(GetToken(CustShipping.cst_ShpName, 1, ” “), “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_firstname>

<ship_lastname>#Replace(Replace(Replace(CustShipping.cst_ShpName,”#GetToken(CustShipping.cst_ShpName, 1, ” “)# “,”"), “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_lastname>

<ship_address1>#Replace(Replace(CustShipping.cst_ShpAddress1, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_address1>

<ship_address2>#Replace(Replace(CustShipping.cst_ShpAddress2, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_address2>

<ship_city>#Replace(Replace(CustShipping.cst_ShpCity, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_city>

<ship_state>#Replace(Replace(CustShipping.stprv_Code, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_state>

<ship_zip>#Replace(Replace(CustShipping.cst_ShpZip, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_zip>

<ship_country>#Replace(Replace(CustShipping.country_Code, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_country>

<ship_phone>#Replace(Replace(CustBilling.cst_Phone, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</ship_phone>

</ship_to>

<continuity>

<enrolled>0</enrolled>

</continuity>

<charges>

<sub_total>#Replace(Replace(Replace(NumberFormat(Client.OrderTotal-(Client.ShipTotal+Client.TaxAmt),’999999999.99′),” “,”",”ALL”), “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</sub_total>

<tax>#Replace(Replace(Replace(NumberFormat(Client.TaxAmt,’999999999.99′),” “,”",”ALL”), “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</tax>

<shipping>#Replace(Replace(Replace(NumberFormat(Client.ShipTotal,’999999999.99′),” “,”",”ALL”), “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</shipping>

<discount>0.00</discount>

<total>#Replace(Replace(Replace(NumberFormat(Client.OrderTotal,’999999999.99′),” “,”",”ALL”), “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</total>

</charges>

<payment>

<payment_status>uncharged</payment_status>

<cc_number>#Replace(Replace(request.CCNumber, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</cc_number>

<cc_expiration_month>#Replace(Replace(request.ExprMonth, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</cc_expiration_month>

<cc_expiration_year>#Replace(Replace(request.ExprYr, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</cc_expiration_year>

<cc_cvv>#Replace(Replace(request.CCV, “>”,”>”,”ALL”), “<”,”<”,”ALL”)#</cc_cvv>

<check_account_number></check_account_number>

<check_routing_number></check_routing_number>

<check_bank_name></check_bank_name>

<check_branch_city></check_branch_city>

<multi_pay_profile></multi_pay_profile>

</payment>

<line_item_count>#numitems#</line_item_count>

<line_items>

#linedata#</line_items>

</call_values>

</orderwave></cfsavecontent></cfoutput>

<cfset strXML = Replace(strXML, “&”,”&”,”ALL”)>

<cfhttp url=”https://app.orderwave.com/api/main.lasso” timeout=”4000″ port=”443″ method=”post”>

<CFHTTPPARAM type=”body” name=”transaction” value=”#strXML.trim()#” encoded=”no”>

<CFHTTPPARAM type=”HEADER” name=”Content-Type” value=”text/xml” encoded=”no”>

</cfhttp>