Pages

Showing posts with label Online Fresh Food Store in HTML. Show all posts
Showing posts with label Online Fresh Food Store in HTML. Show all posts

Wednesday, September 8, 2010

Online Fresh Food Store

The online fresh food store will allow online shopping customers to "place" items in the cart. Upon "checkout" the software will calculate a total for the order including shipping and handling (i.e., postage and packing) and taxes, if applicable. This software will automatically compute the cost and other things for customer and for the company as well and will make it easier for the customer to pay through credit cards.

It will be an easy-to-use shopping cart software. The shopping data will be stored in a flat-file database. The software will be able to process payments through Paypal payment gateway.

Main Features of Online Fresh Food Store:
  • Client-side scripting (Java Script)
  • Secure servers with CGI support if available 
  • Multiple product pages
  • Product quantity selection 
  • Complete 'Manage Cart' web page 
  • Product ID, Name/Description, and amounts will be passed
  • Shipping Costs 
  • Regional Tax Costs 
  • Minimum purchase amount can be configured.
Tools used in Online Fresh Food Store are Java Script, HTML, CSS, Dreamweaver.


    Feasibility Study of Online Fresh Food Store

    Not everything imaginable is feasible. Software feasibility has some solid dimensions
    • Technical Feasibility: Is a project technically feasible? Is it within the state of the art? Can defects be reduced to a level matching the application's needs? The technology is already available for this project like HTML, CSS, Java Script
    • Financial Feasibility: Is it financially feasible? Can development be completed at a cost the software organization, its client, or the market can afford? This software is financially feasible because it will not cost very high.
    • Time Feasibility: Will the project's time to market beat the competition? This project will take three months to develop.
    • Legal Feasibility: Legal feasibility is the determination of any infringement, violation, or the liability that could result from the development of the system. This software is legally faesible because we will be selling fresh fruits and vegetables only.

    Software Engineering Paradigm of 'Online Fresh Food Store'

    The best model for online fresh food store is the prototype model. Software prototyping is the process of creating an incomplete model of the future full-featured software program, which can be used to let the users have a first idea of the completed program or allow the clients to evaluate the program. This has several advantages: The software designer and implementer can obtain feedback from the users early in the project. The client and the contractor can compare if the software made matches the software specification, according to which the software program is built. It also allows the software engineer some insight into the accuracy of initial project estimates and whether the deadlines and milestones proposed can be successfully met.

    The process of prototyping involves the following steps
    • Identify basic requirements: Determine basic requirements including the input and output information desired. Details, such as security, can typically be ignored.
    • Develop Initial Prototype: The initial prototype is developed that includes only user interfaces. 
    • Review: The customers, including end-users, examine the prototype and provide feedback on additions or changes. 
    • Revise and Enhancing the Prototype: Using the feedback both the specifications and the prototype can be improved. Negotiation about what is within the scope of the contract/product may be necessary. If changes are introduced then a repeat of steps #3 ands #4 may be needed.

    SOME ADVANTAGES OF PROTOTYPING
    • Reduced time and costs: Prototyping can improve the quality of requirements and specifications provided to developers. Because changes cost exponentially more to implement as they are detected later in development, the early determination of what the user really wants can result in faster and less expensive software.
    • Improved and increased user involvement: Prototyping requires user involvement and allows them to see and interact with a prototype allowing them to provide better and more complete feedback and specifications. The presence of the prototype being examined by the user prevents many misunderstandings and miscommunications that occur when each side believe the other understands what they said. Since users know the problem domain better than anyone on the development team does, increased interaction can result in final product that has greater tangible and intangible quality. The final product is more likely to be satisfy the users desire for look, feel and performance.
    BEST PROJECTS TO USE PROTOTYPING
    Prototyping is most beneficial in systems that will have many interactions with the users.

    It has been found that prototyping is very effective in the analysis and design of on-line systems, especially for transaction processing, where the use of screen dialogs is much more in evidence. The greater the interaction between the computer and the user, the greater the benefit is that can be obtained from building a quick system and letting the user play with it.

    Systems with little user interaction, such as batch processing or systems that mostly do calculations, benefit little from prototyping. Sometimes, the coding needed to perform the system functions may be too intensive and the potential gains that prototyping could provide are too small.

    Prototyping is especially good for designing good human-computer interfaces. "One of the most productive uses of rapid prototyping to date has been as a tool for iterative user requirements engineering and human-computer interface design."

    Process Map of ''Online Fresh Food Store

    A process map visually depicts the sequence of events to build a product or produce an outcome. It may include additional information such as cycle time, inventory, and equipment information.

    Functions of a Process Map:

    • Determine the beginning and the end of the process
    • Brainstorm the process steps
    • Group processes into major process areas
    • Layout activities in sequence
    • Code each activity
    • Walk through the process thereby validating it.
    Process Map of Online Fresh Food Store:


    Use Case Diagrams of 'Online Fresh Food Store'

    Use cases are used in almost every project.  The are helpful in exposing requirements and planning the project. During the initial stage of a project most use cases should be defined, but as the project continues more might become visible.

    Use cases are a relatively easy UML diagram to draw, but this is a very simplified example.  This example is only meant as an introduction to the UML and use cases.  If you would like to learn more see the Resources page for more detailed resources on UML.

    Start by listing a sequence of steps a user might take in order to complete an action.  For example a user placing an order with a sales company might follow these steps.
    1. Browse catalog and select items.
    2. Call sales representative.
    3. Supply shipping information.
    4. Supply payment information.

    5. Receive conformation number from salesperson.



    Data Flow Diagrams of Online Shopping Cart

    DFD specifies only what processes are performed and not how they are performed it is easily understood by a nonprogramming user.

    Context Level Diagram:
    A diagram giving an entire system’s data flows and processing with a single Process (circle) is called a context diagram. A context diagram is expanded into a number of inter-related processes. Each process may be further expanded into a set of inter-connected sub processes. This procedure of expanding a DFD is known as levelling.

     
















    First Level Diagram:






    Data Flow of Online Shopping Cart (2nd Level)

    Following are the second level DFD of Online Fresh Food Store:


    View/Edit Cart DFD







    Add to Cart DFD:



    Program Structure of Shopping Cart

    Functionally the software online fresh food store can be divided in the following parts:
    Fruits Store: The food store will show available fresh fruits for sale. It will show the details of available fruits: description, fruit ID, name, price, shipping and handling, options, and quantity. The interface will allow the user to easily add the fruits to the shopping cart. The user will also be easily able to view all the available products he has added in the shopping cart.

    Vegetables Store: The vegetables store will show available fresh vegetables for sale. It will show the details of available vegetables: vegetable ID, vegetable name, vegetable price, shipping and handling, any options, and quantity. The quantity can be easily changed. The interface will allow the user to easily add the vegetables to the shopping cart. The user will also be easily able to view all the available products he has added in the shopping cart.

    Meat Store: The meat store will show available fresh meat for sale. It will show the details like: description, product ID, name, price, shipping and handling, any options, and quantity. The quantity can be easily changed. The interface will allow the user to easily add the product to the shopping cart. The user will also be easily able to view all the available products he has added in the shopping cart.

    Manage cart: This module will allow the user to manage the shopping cart. It will show the user all the products that are in his shooping list. The user will be able to easily change the quanity also. It will also allow the user to remove any product from the shooping list. It will show all the details like product ID, quantiy, price per item, shipping price, total cost and tax details, etc. The data is stored locally in the users browser cookies.

    Checkout:
    The checkout part finally shows the user all the details of products in the shooping list. It allows to user to proceed to make payments throrugh credit card via paypal.

    Add to Cart of Online Shopping Cart

    The add to cart button can be used to add a particular product in the shopping cart. The see cart button can be used to view all the products that have been added to the cart. The following details are shown on every page which shows the number of products in the cart.







    //-----------------------------------------------------------||
    // FUNCTION:    AddToCart                                             ||
    // PARAMETERS:  Form Object                                        ||
    // RETURNS:     Cookie to user's browser, with prompt      ||
    // PURPOSE:     Adds a product to the user's shopping cart ||
    //----------------------------------------------------------- ||
    function AddToCart(thisForm) {
       var iNumberOrdered = 0;
       var bAlreadyInCart = false;
       var notice = "";
       iNumberOrdered = GetCookie("NumberOrdered");

       if ( iNumberOrdered == null )
          iNumberOrdered = 0;

       if ( thisForm.ID_NUM == null )
          strID_NUM    = "";
       else
          strID_NUM    = thisForm.ID_NUM.value;

       if ( thisForm.QUANTITY == null )
          strQUANTITY  = "1";
       else
          strQUANTITY  = thisForm.QUANTITY.value;

       if ( thisForm.PRICE == null )
          strPRICE     = "0.00";
       else
          strPRICE     = thisForm.PRICE.value;

       if ( thisForm.NAME == null )
          strNAME      = "";
       else
          strNAME      = thisForm.NAME.value;

       if ( thisForm.SHIPPING == null )
          strSHIPPING  = "0.00";
       else
          strSHIPPING  = thisForm.SHIPPING.value;

       if ( thisForm.ADDITIONALINFO == null ) {
          strADDTLINFO = "";
       } else {
          strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value;
       }
       if ( thisForm.ADDITIONALINFO2 != null ) {
          strADDTLINFO += "; " + thisForm.ADDITIONALINFO2[thisForm.ADDITIONALINFO2.selectedIndex].value;
       }
       if ( thisForm.ADDITIONALINFO3 != null ) {
          strADDTLINFO += "; " + thisForm.ADDITIONALINFO3[thisForm.ADDITIONALINFO3.selectedIndex].value;
       }
       if ( thisForm.ADDITIONALINFO4 != null ) {
          strADDTLINFO += "; " + thisForm.ADDITIONALINFO4[thisForm.ADDITIONALINFO4.selectedIndex].value;
       }

       //Is this product already in the cart?  If so, increment quantity instead of adding another.
       for ( i = 1; i <= iNumberOrdered; i++ ) {
          NewOrder = "Order." + i;
          database = "";
          database = GetCookie(NewOrder);

          Token0 = database.indexOf("|", 0);
          Token1 = database.indexOf("|", Token0+1);
          Token2 = database.indexOf("|", Token1+1);
          Token3 = database.indexOf("|", Token2+1);
          Token4 = database.indexOf("|", Token3+1);

          fields = new Array;
          fields[0] = database.substring( 0, Token0 );
          fields[1] = database.substring( Token0+1, Token1 );
          fields[2] = database.substring( Token1+1, Token2 );
          fields[3] = database.substring( Token2+1, Token3 );
          fields[4] = database.substring( Token3+1, Token4 );
          fields[5] = database.substring( Token4+1, database.length );

          if ( fields[0] == strID_NUM &&
               fields[2] == strPRICE  &&
               fields[3] == strNAME   &&
               fields[5] == strADDTLINFO
             ) {
             bAlreadyInCart = true;
             dbUpdatedOrder = strID_NUM    + "|" +
                              (parseInt(strQUANTITY)+parseInt(fields[1]))  + "|" +
                              strPRICE     + "|" +
                              strNAME      + "|" +
                              strSHIPPING  + "|" +
                              strADDTLINFO;
             strNewOrder = "Order." + i;
             DeleteCookie(strNewOrder, "/");
             SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
             notice = strQUANTITY + " " + strNAME + strAdded;
             break;
          }
       }


       if ( !bAlreadyInCart ) {
          iNumberOrdered++;

          if ( iNumberOrdered > 12 )
             alert( strSorry );
          else {
             dbUpdatedOrder = strID_NUM    + "|" +
                              strQUANTITY  + "|" +
                              strPRICE     + "|" +
                              strNAME      + "|" +
                              strSHIPPING  + "|" +
                              strADDTLINFO;

             strNewOrder = "Order." + iNumberOrdered;
             SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
             SetCookie("NumberOrdered", iNumberOrdered, null, "/");
             notice = strQUANTITY + " " + strNAME + strAdded;
          }
       }

       if ( DisplayNotice )
          alert(notice);
    }

    Home Screen of Online Fresh Food Store





    Home Screen


    The home screen is the main page of the Fresh fruits and vegetables store. It contains links to all product pages and the shopping cart.

    Below is the code for the above home screen shot:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta http-equiv="classification" content="" />
    <meta name="subject" content="" />
    <meta name="copyright" content="copyright(c)" />
    <meta name="creator" content="Nishu Chhabra" />
    <meta name="author" content="nishu_chhabra1986@hotmail.com" />
    <meta name="audience" content="all" />
    <meta name="robots" content="index,follow" />
    <meta name="revisit-after" content="7 days" />
    <meta name="Rating" content="General" />
    <meta name="distribution" content="GLOBAL" />
    <meta name="language" content="Spanish" />
    <link href="_css/screen.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="favicon.ico" />
    <script src="_js/language-en.js"></script>
    <script src="_js/mycart.js">
    </script>

    <title>Online Fresh Food Store!</title>
    </head>
    <body>
    <div id="container">
      <div id="header">
        <h1><a href="index.html">Online Fresh Food Store</a></h1>
        <div id="navcontainer">
          <ul>
            <li><a href="index.html">Home</a></li>
            <li><a href="products/fruit.html">Fruits</a></li>
            <li><a href="products/vegetable.html">Vegetables</a></li>
            <li><a href="products/meat.html">Meat</a></li>
            <li><a href="pages/managecart.html">Shopping cart </a></li>
            <li><a href="#">Contact us </a></li>
          </ul>
        </div>
      </div>
      <div id="content">
        <noscript>
        <p>We detected that your browser does not have JavaScript, or it is disabled.
          Our product catalog requires that you have JavaScript enabled to order products.
          <a href="http://www.netscape.com">Netscape</a> and <a href="http://www.microsoft.com/ie">Microsoft</a>
          offer free browsers which support JavaScript. If you are using a JavaScript
          compliant browser and still have problems, make sure you have JavaScript
          enabled in your browser's preferences.</p>
        </noscript>
        <div id="main">
          <div class="mainCenter">
            <h2>Fresh Food Store</h2>
            <p>A New World of Flavour in Every Bite</a>. </p>
          </div>
          <div class="mainLeft">
            <h3>&nbsp; </h3>
            <p><img src="_img/images/grapes.jpg" width="180" height="180" /> </p>
          </div>
          <div class="mainRight">
            <h3></h3>
            <p>This website is an online food store. Here you can buy </p>
            <p>Fresh Fruits and Vegetables<br />
              Meat<br />
              <br />
              The food will be delivered at your door step within 24 hours.</p>
          </div>
          <div class="clear"></div>
          <div class="mainCenterGreen">
            <p><img src="_img/images/tomato.jpg" width="180" height="180" /> <img src="_img/layout/bowl.gif" width="111" height="83" />
            </p>
          </div>
          <div class="clear"></div>
        </div>
        <div id="sideContent"> <img src="_img/layout/logo_s.gif" alt="The World's finest foods" width="150" height="96" />    <p> </p><p></p>
             <div class="sidecontentbox"> <a href="products/fruit.html"><img src="_img/images/feature3_s.jpg" alt="i" width="128" height="100" border="0" /></a>   
          </div>
          <div class="sidecontentbox"> <a href="products/vegetable.html"><img src="_img/images/feature1_s.jpg" alt="Veggies" width="128" height="100" border="0" /></a>
          </div>
          <div class="sidecontentbox"> <a href="products/meat.html"><img src="_img/images/roast_s.jpg" alt="Meat" width="128" height="100" border="0" /></a>   
          </div>
        </div>
        <div class="clear"></div>
      </div>
      <div id="footer">
        <div id="mc"><b class="mis"></b><span class="chunches"></span></div>
      </div>
    </div>
    </body>
    </html>

    Java Script for MyCart in Online Fresh Food Store

    mycart.js

    //Options
    MonetarySymbol        = '$';
    DisplayNotice         = true;
    DisplayShippingColumn = true;
    DisplayShippingRow    = true;
    DisplayTaxRow         = false;
    TaxRate               = 0.00;
    TaxByRegion           = false;
    TaxPrompt             = 'For tax purposes, please select if you are an Indian resident before continuing';
    TaxablePrompt         = 'Indian Residents';
    NonTaxablePrompt      = 'Other States';
    MinimumOrder          = 0.00;
    MinimumOrderPrompt    = 'Your order is below our minimum order, please order more before checking out.';

    //Payment Processor Options: paypal
    PaymentProcessor      = 'pp';

    //Options for Programmers:
    OutputItemId          = 'ID_';
    OutputItemQuantity    = 'QUANTITY_';
    OutputItemPrice       = 'PRICE_';
    OutputItemName        = 'NAME_';
    OutputItemShipping    = 'SHIPPING_';
    OutputItemAddtlInfo   = 'ADDTLINFO_';
    OutputOrderSubtotal   = 'SUBTOTAL';
    OutputOrderShipping   = 'SHIPPING';
    OutputOrderTax        = 'TAX';
    OutputOrderTotal      = 'TOTAL';
    AppendItemNumToOutput = true;
    HiddenFieldsToCheckout = false;

    Function for removing product from the cart

    //---------------------------------------------------------------------||
    // FUNCTION:    RemoveFromCart                                         ||
    // PARAMETERS:  Order Number to Remove                                 ||
    // RETURNS:     Null                                                   ||
    // PURPOSE:     Removes an item from a users shopping cart             ||
    //---------------------------------------------------------------------||
    function RemoveFromCart(RemOrder) {
       if ( confirm( strRemove ) ) {
          NumberOrdered = GetCookie("NumberOrdered");
          for ( i=RemOrder; i < NumberOrdered; i++ ) {
             NewOrder1 = "Order." + (i+1);
             NewOrder2 = "Order." + (i);
             database = GetCookie(NewOrder1);
             SetCookie (NewOrder2, database, null, "/");
          }
          NewOrder = "Order." + NumberOrdered;
          SetCookie ("NumberOrdered", NumberOrdered-1, null, "/");
          DeleteCookie(NewOrder, "/");
          location.href=location.href;
       }
    }

    Manage Cart Function of Online Fresh Food Store

    //---------------------------------------------------------------------||
    // FUNCTION:    ManageCart                                             ||
    // PARAMETERS:  Null                                                   ||
    // RETURNS:     Product Table Written to Document                      ||
    // PURPOSE:     Draws current cart product table on HTML page          ||
    //---------------------------------------------------------------------||
    function ManageCart( ) {
       var iNumberOrdered = 0;    //Number of products ordered
       var fTotal         = 0;    //Total cost of order
       var fTax           = 0;    //Tax amount
       var fShipping      = 0;    //Shipping amount
       var strTotal       = "";   //Total cost formatted as money
       var strTax         = "";   //Total tax formatted as money
       var strShipping    = "";   //Total shipping formatted as money
       var strOutput      = "";   //String to be written to page
       var bDisplay       = true; //Whether to write string to the page (here for programmers)

       iNumberOrdered = GetCookie("NumberOrdered");
       if ( iNumberOrdered == null )
          iNumberOrdered = 0;

       if ( bDisplay )
          strOutput = "<table id=\"myTable\"><thead><tr><th></th>" +
                      "<th>"+strILabel+"</th>" +
                      "<th>"+strDLabel+"</th>" +
                      "<th>"+strQLabel+"</th>" +
                      "<th>"+strPLabel+"</th>" +
                      (DisplayShippingColumn?"<th>"+strSLabel+"</th>":"") +
                      "<th>"+strRLabel+"</th></tr></thead><tbody>";

       if ( iNumberOrdered == 0 ) {
          strOutput += "<tr><td colspan=\"7\" class=\"alertText\"><center>"+strCEmpty+"</center></td></tr>";
          bDisplay = false;
          strOutput += "</tbody></table>";
       }

       for ( i = 1; i <= iNumberOrdered; i++ ) {
          NewOrder = "Order." + i;
          database = "";
          database = GetCookie(NewOrder);

          Token0 = database.indexOf("|", 0);
          Token1 = database.indexOf("|", Token0+1);
          Token2 = database.indexOf("|", Token1+1);
          Token3 = database.indexOf("|", Token2+1);
          Token4 = database.indexOf("|", Token3+1);

          fields = new Array;
          fields[0] = database.substring( 0, Token0 );                 // Product ID
          fields[1] = database.substring( Token0+1, Token1 );          // Quantity
          fields[2] = database.substring( Token1+1, Token2 );          // Price
          fields[3] = database.substring( Token2+1, Token3 );          // Product Name/Description
          fields[4] = database.substring( Token3+1, Token4 );          // Shipping Cost
          fields[5] = database.substring( Token4+1, database.length ); //Additional Information

          fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
          fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
          fTax        = (fTotal * TaxRate);
          strTotal    = moneyFormat(fTotal);
          strTax      = moneyFormat(fTax);
          strShipping = moneyFormat(fShipping);

          if ( bDisplay ) {
             strOutput += "<tr><th></th><td>"  + fields[0] + "</td>";

             if ( fields[5] == "" )
                strOutput += "<td>"  + fields[3] + "</td>";
             else
                strOutput += "<td>"  + fields[3] + " - "+ fields[5] + "</td>";

             strOutput += "<td><input type=\"text\" name=\"Q\" class=\"formBox\" size=\"2\" value=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></td>";
             strOutput += "<td>"+ MonetarySymbol + moneyFormat(fields[2]) + "/item</td>";

             if ( DisplayShippingColumn ) {
                if ( parseFloat(fields[4]) > 0 )
                   strOutput += "<td>"+ MonetarySymbol + moneyFormat(fields[4]) + "/item</td>";
                else
                   strOutput += "<td>N/A</td>";
             }

             strOutput += "<td><input type=\"image\" src\=\"..\/_img\/btn\/btn_remove.gif\" value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\"></td></tr>";
          }

          if ( AppendItemNumToOutput ) {
             strFooter = i;
          } else {
             strFooter = "";
          }
          if ( HiddenFieldsToCheckout ) {
             strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[0] + "\">";
             strOutput += "<input type=hidden  name=\"" + OutputItemQuantity  + strFooter + "\" value=\"" + fields[1] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemPrice     + strFooter + "\" value=\"" + fields[2] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemName      + strFooter + "\" value=\"" + fields[3] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[4] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
          }

       }

       if ( bDisplay ) {
          strOutput += "<tr><th>"+strSUB+"</th>";
          strOutput += "<td></td><td></td><td></td><td colspan=3>" + MonetarySymbol + strTotal + "</td>";
          strOutput += "</tr>";

          if ( DisplayShippingRow ) {
             strOutput += "<tr><th>"+strSHIP+"</th>";
             strOutput += "<td></td><td></td><td></td><td colspan=3>" + MonetarySymbol + strShipping + "</td>";
             strOutput += "</tr>";
          }

          if ( DisplayTaxRow || TaxByRegion ) {
             if ( TaxByRegion ) {
                strOutput += "<tr><th>"+strTAX+"</th>";
                strOutput += "<td></td><td></td><td></td><td colspan=3>";
                strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\">";
                strOutput += TaxablePrompt + ": " + MonetarySymbol + strTax;
                strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\">";
                strOutput += NonTaxablePrompt + ": " + MonetarySymbol + "0.00";
                strOutput += "</td>";
                strOutput += "</tr>";
             } else {
                strOutput += "<tr><th>"+strTAX+"</th>";
                strOutput += "<td colspan=5>" + MonetarySymbol + strTax + "</td>";
                strOutput += "</tr>";
             }
          }

          if ( !TaxByRegion ) {
             strOutput += "<tr><th>"+strTOT+"</th>";
             strOutput += "<td colspan=5>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</td>";
             strOutput += "</tr>";
          }
          strOutput += "<tr><th></th><td colspan=6><center><input type\=\"image\" src\=\"..\/_img\/btn\/btn_checkout.gif\" border=\"0\"></center></td></tr>";
          strOutput += "</tbody></table>";

          if ( HiddenFieldsToCheckout ) {
             strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
             strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
             strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
             strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
          }
       }
       g_TotalCost = (fTotal + fShipping + fTax);

       document.write(strOutput);
       document.close();
    }

    Function for Validate Cart

    //---------------------------------------------------------------------||
    // FUNCTION:    ValidateCart                                           ||
    // PARAMETERS:  Form to validate                                       ||
    // RETURNS:     true/false                                             ||
    // PURPOSE:     Validates the managecart form                          ||
    //---------------------------------------------------------------------||
    var g_TotalCost = 0;
    function ValidateCart( theForm ) {
       if ( TaxByRegion ) {
          if ( !RadioChecked(eval("theForm."+OutputOrderTax)) ) {
             alert( TaxPrompt );
             return false;
          }
       }

       if ( MinimumOrder >= 0.01 ) {
          if ( g_TotalCost < MinimumOrder ) {
             alert( MinimumOrderPrompt );
             return false;
          }
       }

       return true;
    }

    Function for Checkout in the Cart

    //---------------------------------------------------------------------||
    // FUNCTION:    CheckoutCart                                           ||
    // PARAMETERS:  Null                                                   ||
    // RETURNS:     Product Table Written to Document                      ||
    // PURPOSE:     Draws current cart product table on HTML page for      ||
    //              checkout.                                              ||
    //---------------------------------------------------------------------||
    function CheckoutCart( ) {
       var iNumberOrdered = 0;    //Number of products ordered
       var fTotal         = 0;    //Total cost of order
       var fTax           = 0;    //Tax amount
       var fShipping      = 0;    //Shipping amount
       var strTotal       = "";   //Total cost formatted as money
       var strTax         = "";   //Total tax formatted as money
       var strShipping    = "";   //Total shipping formatted as money
       var strOutput      = "";   //String to be written to page
       var bDisplay       = true; //Whether to write string to the page (here for programmers)
       var strPP          = "";   //Payment Processor Description Field

       iNumberOrdered = GetCookie("NumberOrdered");
       if ( iNumberOrdered == null )
          iNumberOrdered = 0;

       if ( TaxByRegion ) {
          QueryString_Parse();
          fTax = parseFloat( QueryString( OutputOrderTax ) );
          strTax = moneyFormat(fTax);
       }

       if ( bDisplay )
          strOutput = "<table id=\"myTable\"><thead><tr>" +
                      "<th>"+strILabel+"</th>" +
                      "<th>"+strDLabel+"</th>" +
                      "<th>"+strQLabel+"</th>" +
                      "<th>"+strPLabel+"</th>" +
                      (DisplayShippingColumn?"<th>"+strSLabel+"</th>":"") +
                      "</tr></thead>";

       for ( i = 1; i <= iNumberOrdered; i++ ) {
          NewOrder = "Order." + i;
          database = "";
          database = GetCookie(NewOrder);

          Token0 = database.indexOf("|", 0);
          Token1 = database.indexOf("|", Token0+1);
          Token2 = database.indexOf("|", Token1+1);
          Token3 = database.indexOf("|", Token2+1);
          Token4 = database.indexOf("|", Token3+1);

          fields = new Array;
          fields[0] = database.substring( 0, Token0 );                 // Product ID
          fields[1] = database.substring( Token0+1, Token1 );          // Quantity
          fields[2] = database.substring( Token1+1, Token2 );          // Price
          fields[3] = database.substring( Token2+1, Token3 );          // Product Name/Description
          fields[4] = database.substring( Token3+1, Token4 );          // Shipping Cost
          fields[5] = database.substring( Token4+1, database.length ); //Additional Information

          fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
          fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
          if ( !TaxByRegion ) fTax = (fTotal * TaxRate);
          strTotal    = moneyFormat(fTotal);
          if ( !TaxByRegion ) strTax = moneyFormat(fTax);
          strShipping = moneyFormat(fShipping);

          if ( bDisplay ) {
             strOutput += "<tbody><tr><th>"  + fields[0] + "</th>";

             if ( fields[5] == "" )
                strOutput += "<td>"  + fields[3] + "</td>";
             else
                strOutput += "<td>"  + fields[3] + " - "+ fields[5] + "</td>";

             strOutput += "<td>" + fields[1] + "</td>";
             strOutput += "<td>"+ MonetarySymbol + moneyFormat(fields[2]) + "/item</td>";

             if ( DisplayShippingColumn ) {
                if ( parseFloat(fields[4]) > 0 )
                   strOutput += "<td>"+ MonetarySymbol + moneyFormat(fields[4]) + "/item</td>";
                else
                   strOutput += "<td>N/A</td>";
             }

             strOutput += "</tr>";
          }

          if ( AppendItemNumToOutput ) {
             strFooter = i;
          } else {
             strFooter = "";
          }


    if ( PaymentProcessor == 'pp' ) {
    //Process hidden values for PayPal.
    strOutput += "<input type=hidden name=\"item_number_"+ strFooter + "\" value=\"" + fields[0] + "\">";
    strOutput += "<input type=hidden name=\"quantity_" + strFooter + "\" value=\"" + fields[1] + "\">";
    strOutput += "<input type=hidden name=\"amount_" + strFooter + "\" value=\"" + fields[2] + "\">";
    strOutput += "<input type=hidden name=\"item_name_" + strFooter + "\" value=\"" + fields[3] + "\">";
    if (i == iNumberOrdered) {
    strOutput += "<input type=hidden name=\"shipping_" + strFooter + "\" value=\"" + strShipping + "\">";
    } else {
    strOutput += "<input type=hidden name=\"shipping_" + strFooter + "\" value=\"0.00\">";
    }
    strOutput += "<input type=hidden name=\"on0_" + strFooter + "\" value=\"" + fields[5] + "\">";
    }


          if ( PaymentProcessor != '' ) {
             //Process description field for payment processors instead of hidden values.
             //Format Description of product as:
             // ID, Name, Qty X
             strPP += fields[0] + ", " + fields[3];
             if ( fields[5] != "" )
                strPP += " - " + fields[5];
             strPP += ", Qty. " + fields[1] + "\n";
          } else {
             strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[0] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemQuantity  + strFooter + "\" value=\"" + fields[1] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemPrice     + strFooter + "\" value=\"" + fields[2] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemName      + strFooter + "\" value=\"" + fields[3] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[4] + "\">";
             strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
          }

       }

       if ( bDisplay ) {
          strOutput += "<tr></tr><tr><th>"+strSUB+"</th>";
          strOutput += "<td></td><td></td><td></td><td>" + MonetarySymbol + strTotal + "</td>";
          strOutput += "</tr>";

          if ( DisplayShippingRow ) {
             strOutput += "<tr><th>"+strSHIP+"</th>";
             strOutput += "<td></td><td></td><td></td><td>" + MonetarySymbol + strShipping + "</td>";
             strOutput += "</tr>";
          }

          if ( DisplayTaxRow || TaxByRegion ) {
             strOutput += "<tr><th>"+strTAX+"</th>";
             strOutput += "<td></td><td></td><td></td><td>" + MonetarySymbol + strTax + "</td>";
             strOutput += "</tr>";
          }

          strOutput += "<tr><th>"+strTOT+"</th>";
          strOutput += "<td></td><td></td><td></td><td>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</td>";
          strOutput += "</tr>";

          strOutput += "</tbody></table>";

       }

       document.write(strOutput);
       document.close();
    }

    Function to print total products in the cart

    //---------------------------------------------------------------------||
    // FUNCTION: Print_total                                               ||
    // PARAMETERS: true/false if you want MonetarySymbol added to string   ||
    // RETURNS: Total cost currently racked up by shopper                  ||
    // PURPOSE: Aesthetics                                                 ||
    //---------------------------------------------------------------------||
    function Print_total(bSymbol) {
    var strOutput = ""; //String to be written to page
    var strTotal = ""; //Total cost formatted as money
    var fTotal = 0;
    var iNumberOrdered = 0; //Number of products ordered

    iNumberOrdered = GetCookie("NumberOrdered");
    if ( iNumberOrdered == null )
    iNumberOrdered = 0;

    for ( i = 1; i <= iNumberOrdered; i++ ) {

    NewOrder = "Order." + i;
    database = "";
    database = GetCookie(NewOrder);

    Token0 = database.indexOf("|", 0);
    Token1 = database.indexOf("|", Token0+1);
    Token2 = database.indexOf("|", Token1+1);
    Token3 = database.indexOf("|", Token2+1);
    Token4 = database.indexOf("|", Token3+1);

    fields = new Array;
    fields[0] = database.substring( 0, Token0 ); // Product ID
    fields[1] = database.substring( Token0+1, Token1 ); // Quantity
    fields[2] = database.substring( Token1+1, Token2 ); // Price
    fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
    fields[4] = database.substring( Token3+1, Token4 ); // Weight
    fields[5] = database.substring( Token4+1, database.length ); //Additional Information

    fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
    }
    strTotal = moneyFormat(fTotal);
    strOutput+=strTotal;
    if ( bSymbol )
       strOutput = MonetarySymbol + strOutput
    document.write(strOutput);
    }

    Function to print total products in Online Fresh Food Store

    //---------------------------------------------------------------------||
    // FUNCTION: Print_total_products                                      ||
    // PARAMETERS: true/false if you want "item(s)" added to string        ||
    // RETURNS: Total cost currently racked up by shopper                  ||
    // PURPOSE: Aesthetics                                                 ||
    //---------------------------------------------------------------------||
    function Print_total_products(bVerbose) {
    var strOutput = ""; //String to be written to page
    var fTotal = 0;
    var iNumberOrdered = 0; //Number of products ordered

    iNumberOrdered = GetCookie("NumberOrdered");
    if ( iNumberOrdered == null )
    iNumberOrdered = 0;

    for ( i = 1; i <= iNumberOrdered; i++ ) {

    NewOrder = "Order." + i;
    database = "";
    database = GetCookie(NewOrder);

    Token0 = database.indexOf("|", 0);
    Token1 = database.indexOf("|", Token0+1);
    Token2 = database.indexOf("|", Token1+1);
    Token3 = database.indexOf("|", Token2+1);
    Token4 = database.indexOf("|", Token3+1);

    fields = new Array;
    fields[0] = database.substring( 0, Token0 ); // Product ID
    fields[1] = database.substring( Token0+1, Token1 ); // Quantity
    fields[2] = database.substring( Token1+1, Token2 ); // Price
    fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
    fields[4] = database.substring( Token3+1, Token4 ); // Weight
    fields[5] = database.substring( Token4+1, database.length ); //Additional Information

    fTotal += (parseInt(fields[1]));
    }

    strOutput+=fTotal;
    if ( bVerbose ) {
       if (fTotal == 1) {
          strOutput+=" </span> item</a></p>"
       }
       else {
          strOutput+=" </span> items</a></p>"
       }
    }
    document.write(strOutput);
    }

    FUNCTION for Cart if its empty in 'Online Fresh Food Store'

    //---------------------------------------------------------------------||
    // FUNCTION: Cart_is_empty                                             ||
    // PARAMETERS: none                                                    ||
    // RETURNS: Total true if cart is empty, false otherwise               ||
    // PURPOSE: Aesthetics                                                 ||
    //---------------------------------------------------------------------||
    function Cart_is_empty( ) {
       iNumInCart = GetCookie("NumberOrdered");

       if ( iNumInCart == null ) iNumInCart = 0;

       if ( iNumInCart == 0 ) return true;

       return false;

    }

    Validation Checks done in 'Online Fresh Food Store'

    Few checks and validations that are performed by the software are listed below:
    • If the language is not defined, the default language will be english.
    • If a particular product is already added in the cart and the user again presses the “add to cart button”, the quantity will be incremented instead of adding the same product again.
    • If the user removes a product from the shopping cart, the software confirms by showing a message before deleting the product.
    • If there is no product in the shopping cart and the user views the manage cart page, the checkout button is not displayed. 
    • If the ordered amount is less than the minimum order amount then a promt will be shown to the user.
    • The following details must be specified while providing the billing information: country, name, card information, address, city, email and phone number.
    • If the quantity is updated on the shopping cart page then the total is calculated again.

    Software Testing Techniques used in 'Online Fresh Food Store'

    Software testing is a critical element of software quality assurance and represents the ultimate review of specification, design, and code generation. The increasing visibility of software as a system element and the attendant costs associated with a software failure are motivating forces for well planned, through testing.
    The main objectives of testing are listed below:
    • Testing is a process of executing a program with the intent of finding an error.
    • A good test case is one that has a high probability of finding an as-yet-undiscovered error. 
    • A successful test is one that uncovers an as-yet-undiscovered error.
    Software is tested from two different perspectives: (1) internal program logic is exercised using "white-box" test case design techniques. (2) Software requirements are exercised using "black-box" test case design techniques. In both cases, the intent is to find the maximum number of errors with the minimum amount of effort and time.

    Following are the two types of techniques, which have been used to test this project:
    • White-box testing
    • Black-box testing
    • Condition Testing
    The condition testing method focuses on testing each condition in the program. Condition testing is a test case design method that exercises the logical conditions contained in a program module. A simple condition is a Boolean variable or a relational expression, possibly preceded with one NOT (-) operator. A relational expression takes the following form:
    E1 < relational operator> E2

    Where E1 and E2 are arithmetic expressions and <relational-operator> is one of the following: <, ³ , =, ¹ , £ , >. A compound condition is composed of two or more simple conditions, Boolean operators, and parentheses. A condition without relational expressions is referred to as a Boolean expression. The possible types of elements in a condition include a Boolean operator, a Boolean variable, a pair of Boolean parentheses, a relational operator, or an arithmetic operator. If a condition is incorrect, then at least one component of the condition is incorrect. Therefore, types of errors in a condition include the following
    • Boolean operator error
    • Boolean variable error 
    • Boolean parenthesis error 
    • Relational operator error
    • Arithmetic expression error
    The purpose of condition testing is to detect not only errors in the conditions of a program but also other errors in the program. A number of condition testing strategies have been proposed. Branch testing is the simplest condition testing strategy. For a compound condition C, the true and false branches of C and every condition in C need to be executed at least once. Domain testing requires three or four tests to be derived for a relational expression. For a relational expression of the form.
    E1 <relational operator> E2
    Three tests are required to make the value of E1 grater than, equal to, or less than that of E2. If relational operator is incorrect and E1 and E2 are correct, then these three tests guarantee the detection of the relational operator error.
    For a Boolean expression with n variables, all of 2n possible tests are required (n>0). This strategy can detect Boolean operator, variable, and parenthesis errors, but it is practical only if n is small. Error-sensitive tests for Boolean expressions can be derived. For a singular Boolean expression, we can easily generate a test set with less than 2n tests such that this test set guarantees the detection of multiple boolean operator errors and is also effective for detecting other errors.
    For example, in this project, the following code segment checks if an item is already present in the shopping cart then instead of adding the same product again, the quantity is incremented.
    if ( !bAlreadyInCart ) {
          iNumberOrdered++;
    }
    A technique called BRO (branch and relational operator) testing technique guarantees the detection of branch and relational operator errors in a condition provided that all Boolean variables and relational operators in the condition occur only once and have common variables. The BRO strategy uses condition constraints for a condition C. A condition constraint for C with n simple conditions is defined as (D1, D2, …, Dn), where Di (0 < i £ n) is a symbol specifying a constraint on the outcome of the ith simple condition in condition C. A condition constraint D for condition C is said to be covered by an execution of C if, during this execution of C, the outcome of each simple condition in C satisfies the corresponding constraint in D.

    For a Boolean variable, B, we specify a constraint on the outcome of that states that B must be either true or false. Similarly, for a relational expression, the symbols >, =, < are used to specify constraints on the outcome of the expression. Consider the following example:
    C1 : B1 & B2

    Where B1 and B2 are Boolean variables. The condition constraint C1 is of the form (D1, D2), where each D1 and D2 is t or f. The value (t, f) is a condition constraint for C1 and is covered by the test that makes the value of B1 to be true and all the value of B2 false. The BRO testing strategy requires that the constraint set {(t, t), (f, t), (t, f)} be covered by the executions of C1. If C1 is incorrect due to one or more Boolean operator errors, at least one of the constraint set will force C1 to fail.