Integrating your Internal Inventory Database with Volusion using Volusion API in Real Time
A few days ago, I was asked to develop a solution for one of our Ecommerce clients.. We were discussing how to implement this integration solution and my Project Manager said “the client’s site is hosted with Volusion”.
The first question that came into my mind was “What is Volusion?” At that moment, I thought that Volusion was one of the thousands of shopping cart software that exist on the web. But I didn’t want to interrupt him, so I let him finish presenting the problem, and then there would be time for my questions.
Let me clarify this before continuing. We (programmers) do not usually go thinking in terms of what a product is; we don’t have time to know about thousands of products that are popping up on the web every day. However, once we know what a product is and what it does (usually we are told by someone else), we think in terms of “how it works”, “how it was developed” and “how it can be improved”. This makes us amongst the biggest critics in the world. But trust me; this is something we do unconsciously and we learn to control it with experience.
The project was to update our client’s website from their internal inventory system “without touching” our client’s inventory system; and it had to be automated, of course. In plain English, my Project Manager was obviously meant “without touching the database”. The expression on his face suggested that it was not something easy; but the only thing on my mind was still on “What is Volusion?”. I was also hoping that this Volusion thing had an API; it was all I could think on that moment.
What is Volusion?
Volusion is an online ecommerce platform that enables you to build an online store without knowing any coding at all. It is web-based e-commerce software which means that a user can operate the entire store through the Volusion website via a private account. It’s a turn-key solution because it comes with tools to build an online store. It is a framework.
Volusion. strictly from a programmer’s point of view, this was a relief because what it all means to me is that Volusion has an API.
What is an API?
API stands for “Application Program Interface”. It is a set of routines and protocols that provide building blocks for computer programmers and web developers to build software applications. In its most basic form, it is a non-user-interface application that returns results based on specific commands; in other words you can speak to it and it’s logical. Technically speaking, we aren’t concerned with the way the tasks are executed, we just need to know how to speak to the system using know commands to actually execute the various tasks. We only need to know how to call-up those functions, what arguments need to be passed and what type of results it returns. In other words, we don’t care how the TV works inside the box; we only need to know what buttons need to be pushed.
An API is for technology what the BCL (Base Classes Library) is for the .Net Framework. This clearly tells us that an API is not a Framework.
In the past, APIs were largely associated with computer operating systems and desktop applications. In recent years though, we have seen the emergence of APIs offered for Web Services. (Web APIs)
Web APIs have experienced an exponential increase in popularity and usage in the past few years. These days, they’re an important tool for web developers; however, they are also even becoming an effective marketing tool for many online businesses.
The Volusion API
The Volusion API seems to have been developed in .Net, most specifically in C#, which is a language of the .Net framework. From my prospective, I don’t think that there could be a better framework to build this kind of API, beyond .Net, and C# as the main language of that platform was, without doubt, the best language to develop it. It is this combination of factors that makes the Volusion API so valuable for online marketers and web programmers. Once you get the hang of it, the Volusion API is really pretty easy to work with … once you get the hang of it.
The Volusion API Documentation
A Windows Server was needed
We had no other option but to move to a windows server to build our solution and call the API ASP/VBSCript or C#. We decided on ASP/VBSCript because of the resources, at the end the results would be the same in this specific case. We could have selected C#, but why not ASP?
We provided an XML template for our client with “the format” of how the data should be and a domain where that XML should be automatically placed. By doing this, we can grab the XML “on the fly”.
The XML template
set xmlHTTP = server.createobject("MSXML2.XMLHTTP") xmlHTTP.open "Get", "http://www.myxml.com/myxml.xml", false xmlHTTP.send() xmlDoc = xmlHTTP.ResponseText Set objXMLDoc = CreateObject("Microsoft.XMLDOM") objXMLDoc.async = False objXMLDoc.LoadXml(xmlDoc)
In the previous lines of code, we created an XMLHTTP object and got the XML file into the xmlDoc field. Then, it was necessary to set an XMLDOM object to be able of loading the xmlDoc field as a real XML file, in other words; as an XML object.
Next step was calling the selectNodes() function of the objXMLDoc object that returns an array of “node” objects. At this point, the field “Codes” will contain the values “141428” and “141429” from the XML, but as nodes, I mean as objects, not as single strings.
Set Codes = objXMLDoc.documentElement.selectNodes("Product/ProductCode")
After this, we created a list where to store the “Text” property of the “Node” elements and iterate them.
Set a_Codes = Server.CreateObject ("Scripting.Dictionary") key = 0 For Each Code in Codes a_Codes.Add key, Code.text key = key + 1 Next
Finally, we created a virtual XML, already parsed in order to be passed to the API and to update the Feed for Volusion. I highly recommend creating the XML for every node.
For i=0 to a_Codes.Count-1 api_request = "" api_request = api_request & "" api_request = api_request & "" api_request = api_request & " " api_request = api_request & " "&a_Codes(i)&"" api_request = api_request & " " api_request = api_request & "" dim oXMLHttp set oXMLHttp = Server.CreateObject("Msxml2.serverXmlHttp") oXMLHttp.open"POST","https://www.domain.com/net/WebService.aspx?Login=username &EncryptedPassword=password_encripted&Import=Insert-Update", False oXMLHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=utf-8" oXMLHttp.setRequestHeader "Content-Action", "Volusion_API" oXMLHttp.send(api_request) response.Write oXMLHttp.responseText & vbCrLf Next
The Final step
The final step is to create an ASP file where all the previous code should go and finally call that ASP file using Ajax. I could use AJAX-JQuery but the way to control this is real simple, and irrelevant to this article. It really depends widely on specific objectives and functionalities.
I would like to add that Volusion seems to be well designed although there are things in its API that need to be tweaked and optimized. It would be cool if they provided libraries with base classes to “talk” with Volusion, instead of naming the URL “web services”. Perhaps they could use the Windows Communications Foundations. The most difficult part was already developed by them in .NET, Why not use WCF and provide more tools for the users and clients?
I’m pretty sure that many Volusion customers might be running into this problem where they need to integrate their internal inventories with their Volusion stores in real time.
Let us know your comments and contact us if you feel you need help.