Design of Online Shopping Cart

9.4 Design of Online Shopping Cart

9.4.1 Online Shopping Cart and Implementation Technology

1. Definitions and analysis of online shopping cart

Online shopping cart is the necessary shopping tool for customers doing online shopping. It is used to temporarily store the selected commodity of users, to assist customers to choose commodity, take commodity, and check out in the virtual cash table.

The implementation of online shopping cart is not as simple as explained above. In fact, online shopping cart script is hard to create. Because, first, the design of Web is stateless, namely all Web servers process URL request in the same way, independent from any foregoing request; second, explorer is also works in a stateless way, and deals with the new URL, independent from foregoing request. Server cannot remember user, and cannot identify whether it is the first access or the thousandth access. The stateless mode makes Web server faster and more efficient, and needs not to maintain information of explorers which request URL. However it still leads to many disgusting problems— online shopping cart is one of the main examples of those problems. When a customer selects some commodity and puts it in his virtual online shopping cart, he needs to remember which commodity he has selected so that he will know how much to pay when arriving at virtual cash counter. Servers cannot remember the information and also cannot make users re-input the selected commodity information each time when users see a new page, so script is needed to record all information of selected commodity by users.

2. Implementation technology of online shopping cart

To implement design of online shopping cart system, solve stateless connection of Web application and keep Web page state information of explorer side (information of commodity in the online shopping cart), implicit form field manner and Cookie manner used in HTTP protocol are adopted currently.

(1) Implicit Form Field Manner: Script of online shopping cart type can solve stateless connection problem with implicit field. Then the implicit information after last call can be got when user invokes explorer again. All commodities in online shopping cart have three properties: quantity, price and commodity description. When one selects one kilogram oranges which are 3 yuan per kilogram, online shopping cart will write string “1/3/Orange” into implicit field, in the string, semicolon indicates the end of the record, and fields in the record are separated by slash, and a long string composed of any number records is allowed. When it needs to separate information, online shopping cart can separate selected commodity simply by searching for the semicolon and slash. The implicit field is

9 Portal Site Design of Virtual Enterprise

not displayed and unchangeable for users. The implicit field form of online shopping cart is dynamically created when CGI program processes data submitted by other forms. When the server sends message to the explorer, CGI program write all commodity information to the script in the implicit field manner. When the user submits forms including implicit fields, the commodity information formerly stored in the field is returned to the server, and the server separates the commodity information in implicit fields, thereby the commodity information is preserved in the online shopping cart.

(2) Cookie Manner: Cookie is one way to continuously preserve state information and other information, and the information is preserved in the different explorer session periods. Cookie is composed of information sent by server which responses to the explorer URL request. According to the URL of the CGI program, Cookie preserves the information in the local Cookies.txt file of the explorer, and the URL can be unified according to the other information in the Cookie. When the explorer requests a URL from the Web server, the explorer searches for the Cookies.txt file to examine whether some URL request of Cookie accords with the requested URL, and then the explorer sends the information in the Cookie which accords with the request in the URL request to the Web server. In the process of implementing the online shopping cart, when the user chooses the commodity and puts it in the online shopping cart, the system processes in Cookie manner, which writes the information of the selected commodity in the form of text string in the local Cookies.txt of the explorer. When the online shopping cart is activated next time, Cookie manner will read the corresponding text string information in the local Cookies.txt of the explorer, to get the information of the selected commodity in the online shopping cart.

9.4.2 Database of Online Shopping Cart and Actual Implementation Policy

1. Design ideology of online shopping cart based on database technology

Through the analysis above, it is not hard to figure out that the online shopping cart program is a script difficult to program, which is hard to be implemented by both implicit script and Cookie. Therefore, this section introduces a new method using database technology to implement online shopping cart.

To steer clear of the stateless connection characteristic of Web, and save or get information of online shopping cart at any moment, more mature Web database technology should be used to design online shopping cart, making use of the characteristics of DBMS, such as convenient access, security, easy operation and powerful computation. The information of commodity in the online shopping cart is stored in database, and is picked up from the database when needed. Because every Internet user corresponds to one IP address and the IP address can

Introduction to E-commerce

be gained through CGI, what a user accesses is actually the Web server of the virtual shop when the user accesses the virtual shop through an explorer. When the user puts forward the purchase request or wants to update information of a selected commodity, the online shopping cart is activated, and Web server interoperates with the database server, operating tables of online shopping cart data on the database server, completing the operations of updating the data record of user selected commodity and updating commodity information in the online shopping cart. At the same time, the commodity in the online shopping cart can

be stored securely and gathered statistically.

2. Implementation of online shopping cart based on database technology

The data table structure of online shopping carts in accordance with the above analysis is shown in Table 9.2.

Table 9.2 Data structure of data table of online shopping cart

Field Name Data Type

Length

Null

Code Varchar 15 Not null Name

Varchar 50 Not null Price

Null Number

Decimal

Int Null IP

Char 16 Not null

The online shopping cart mainly implements the following functions: users put selected commodity into the online shopping cart; delete commodity in the shopping cart; update the amount information of commodity in the shopping cart; sum up the total price information of commodity in the shopping cart. These four functions are all implemented with CGI program. When user’s explorer put forward a URL request, which triggers CGI program in Web server, CGI script reads environment variables and STDIN, and builds up connection with the database through database interface, applying SQL statements to operate database, sending the correct MIME head information and its HTML output part to STDOUT. Customers can freely look around in the marketplace, if customers want to purchase something, the CGI script of shopping cart in the server will be activated, and the CGI script reads environment variables to acquire IP address information of the customer’s explorer, request information of purchasing commodity, and writes these information to the data table of shopping cart in the database. Similarly, CGI script can provide the commodity selected into shopping cart in the form of list for users to check, and also provide commodity price statistics and payment result.

Part of function modules implementation of online shopping cart is given in the following section.

(1) Commodity selected by customer is put into the shopping cart: In the data

9 Portal Site Design of Virtual Enterprise

table, each commodity owns a commodity number, which hides in HTML script in the form of implicit field. When a user clicks “put into shopping cart”, the shopping cart CGI script is triggered to do the following work: getting the explorer IP address information (strcpy (IP, getenv(“REMOTE-ADDR”))); Acquiring and decomposing the commodity number which is purchased from the environment variables (GetData(), ProcessData()); Connecting to database, and finding the name and price of corresponding commodity from the commodity table according to the commodity number, and setting the default amount of purchasing to 1, and assigning these information separately to the corresponding variables; Writing these commodity information and IP address information to shopping cart data table (if the commodity information already exists in the online shopping cart, the amount of the commodity pluses 1); selecting and listing all commodity and price information in the online shopping cart data table in the form of list for customers; disconnecting to database. Page output is transformed to the corresponding HTML script output with C program when the page is displayed.

(2) Deletion operation on commodity in user’s online shopping cart Triggered by a user, the deletion script first gets the number information of

commodity to be deleted from environment variables in the way of GET from the HTML implicit script, then connect to the database, delete the commodity from the shopping cart data table according to the acquired commodity number and IP address information, then list output of information of commodity in the online shopping cart, at last disconnect to the database.

(3) Updating amount information of commodity in the online shopping cart Every time the online shopping cart is activated, the amount of commodity in

the cart is different. However, what to be decomposed of the saved commodity information from pages in the environment variables is required to be the fixed data, thus it’s hard to determine the corresponding relation between the code and amount, and also hard to update data in the shopping cart data table. The update of system amount adopts POST manner. The state information from online shopping cart script (code and amount for all commodity in the shopping cart) is saved in the form of string, whose format is as (code1 000001˂number1 3˂ code2 000006˂number2 4…), where code is written in the script in the implicit manner when the commodity content list in the online shopping cart is displayed, and number information is written in the script in the form of input textbox, the name of which is automatically defined through a cyclic manner. Because of the unfixed amount, the length of saved string is also undetermined, in program implementation, the commodity information with fixed amount can freely be changed adopting queue technology and written back into database. First we define two queues, then decompose the string, compute amount information of all commodities, and decompose them one by one; put the decomposed information of code in the first queue, and put the corresponding amount information in the second queue, then complete the decomposition of all

Introduction to E-commerce

the strings in a loop manner, and then connect to the database and get the code and amount of the commodity information from the two queues separately, and update amount information of data table according to the code and IP address information until the queue information is null, the loop finishes; output the list of commodity information updated in the shopping cart, at last disconnect to database, and complete the update operation on the amount information of commodity.

(4) Summing up the price information of commodities in user’s shopping cart This function implements price subtotal of single commodity information in

the shopping cart and the total price of all commodities and provides them to users. The price information of commodity in the shopping cart can be computed with the sum function of standard SQL statement, and by this we can realize the function of summing up all price information of commodity in the online shopping cart.

Dokumen yang terkait

AN ALIS IS YU RID IS PUT USAN BE B AS DAL AM P E RKAR A TIND AK P IDA NA P E NY E RTA AN M E L AK U K A N P R AK T IK K E DO K T E RA N YA NG M E N G A K IB ATK AN M ATINYA P AS IE N ( PUT USA N N O MOR: 9 0/PID.B /2011/ PN.MD O)

0 82 16

Anal isi s L e ve l Pe r tanyaan p ad a S oal Ce r ita d alam B u k u T e k s M at e m at ik a Pe n u n jang S MK Pr ogr a m Keahl ian T e k n ologi , Kese h at an , d an Pe r tani an Kelas X T e r b itan E r lan gga B e r d asarkan T ak s on om i S OL O

2 99 16

The Effectiveness of Computer-Assisted Language Learning in Teaching Past Tense to the Tenth Grade Students of SMAN 5 Tangerang Selatan

4 116 138

Modul TK E 2016 150 hlm edit Tina M imas

2 44 165

Membangun aplikasi e-commerce pada Toko Reafshop Bandung

1 26 687

Pengaruh Persepsi Kemudahan dan Kepuasan Wajib Pajak Terhadap Penggunaan E Filling (Survei Pada Wajib Pajak Orang Pribadi Di Kpp Pratama Soreang)

12 68 1

PENGARUH ARUS PENGELASAN TERHADAP KEKUATAN TARIK PADA PENGELASAN BIMETAL (STAINLESS STEEL A 240 Type 304 DAN CARBON STEEL A 516 Grade 70) DENGAN ELEKTRODA E 309-16

10 133 86

Factors Related to Somatosensory Amplification of Patients with Epigas- tric Pain

0 0 15

TEKNIK PERLAKUAN PENDAHULUAN DAN METODE PERKECAMBAHAN UNTUK MEMPERTAHANKAN VIABILITAS BENIH Acacia crassicarpa HASIL PEMULIAAN (Pretreatment Technique and Germination Method to Maintain the Viability of Acacia crassicarpa Improved Seed)

0 1 11

The Risk and Trust Factors in Relation to the Consumer Buying Decision Process Model

0 0 15