500+ items in the basket

Completed modifications to the NOP Shopping Cart. Additions, modifications, and more.

Moderators: Koibito, Stefko, Randy, Rosey

500+ items in the basket

Postby NetteDesign » Thu Nov 08, 2007 11:28 am

I have an e-shop that is build on a frameset. This makes it possible to replace the cookies with a Javascript Array in a static frame. I changed all calls to building, altering and deleting cookies to calls to functions in the static frame. This way there is no limitation to the number of items in the basket.

Code: Select all
<SCRIPT type="text/javascript">
CartArray = new Array()

function GetCart(ArrNum) {
  return CartArray[ArrNum];
}

function SetCart(ArrNum,CartVal) {
  CartArray[ArrNum] = CartVal
}

function NumCart() {
  return CartArray.length
}

function DelCart(ArrNum) {
  CartArray.splice(ArrNum,1)
}

function ZeroCart() {
  CartArray.splice(0,CartArray.length)
}
</SCRIPT>

You are welcome to see it live at http://www.nettedesign.dk
But please do not complete the order unless you want to order
Sorry the site is in danish. "Butik" means "Shop"

best regards,
Annette
NetteDesign
WebMaster
 
Posts: 4
Joined: Fri Feb 24, 2006 2:36 pm
Location: Denmark

Re: 500+ items in the basket

Postby Koibito » Thu Nov 08, 2007 1:28 pm

This is very interesting. I want to implement this too. I haven't looked at your code yet, but could you please give a few additional details?
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Re: 500+ items in the basket

Postby NetteDesign » Thu Nov 08, 2007 1:54 pm

The idea is to replace calls that handles the cookie with calls to the functions that I mentioned above.

I here list one modification to the nopcart.js, but there are many more:

Code: Select all
function AddToCart(thisForm) {
...
         top.SetCart(i,dbUpdatedOrder);
...
   if ( !bAlreadyInCart ) {

         dbUpdatedOrder = strID_NUM    + "|" +
                          strQUANTITY  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strADDTLINFO;

         top.SetCart(iNumberOrdered,dbUpdatedOrder);
...
}

The "top.SetCart" is the new code

The content of the Array, is then the same as what was in the cookie.
NetteDesign
WebMaster
 
Posts: 4
Joined: Fri Feb 24, 2006 2:36 pm
Location: Denmark

Re: 500+ items in the basket

Postby Mina » Thu May 29, 2008 8:29 pm

Hi! I don't use any frame in my website, can I use this way to get rid of the limitation of the items in the shopping cart then? I've been in your shop and it's very nice! I'm also interested in the "search" function there, how did you make that? You can have a look at my shop, it's in Norwegian, so you won't have problem to find your way! http://www.flinkmamma.com for the index page, or http://www.flinkmamma.com/Clothes-all-01.html for the first page of the shop. This is an active shop, so please don't send in orders unless you really want to order anything! :wink:
Mina
WebMaster
 
Posts: 5
Joined: Thu May 29, 2008 6:01 am

Re: 500+ items in the basket

Postby bossturbo » Tue Jun 24, 2008 11:03 pm

Hi NetteDesign,

Thank you for your post! Is it possible you could post a bit more info. I've modified my NOPcart to do everything I need it to do except allow more items and I didn't quite follow your instructions. Can you post your source code, or some more examples if you don't want to put all your code up here?

Please feel free to send me a private message also,
-brian
bossturbo
WebMaster
 
Posts: 2
Joined: Tue Jun 24, 2008 10:59 pm

Re: 500+ items in the basket

Postby bossturbo » Sun Jun 29, 2008 3:43 am

nevermind I eventually got it to work!
bossturbo
WebMaster
 
Posts: 2
Joined: Tue Jun 24, 2008 10:59 pm

Re: 500+ items in the basket

Postby Koibito » Sun Jun 29, 2008 4:03 pm

Please tell us how you got it to work.
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Re: 500+ items in the basket

Postby grenooye » Wed Oct 08, 2008 8:17 am

Having to same need for unlimited capacity, I spent hours to work this out and want to share my results to other members needing to expend the capacity of their Cart!
A to Z of this feature:
1- You need to create a frameset with the 'hidden' frame for your Cart data:
Code: Select all
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="*,0" border="0" framespacing="0" frameborder="0">
  <FRAME SRC="body.html" NAME="Main" >
  <FRAME SRC="CartData.html" NAME="CartData" >
  </FRAMESET>
</HTML>

Save this page as: index.html

2- Create your Cart Data page:
Code: Select all
<html><head>
  <script language="JavaScript">
  var CartArray = new Array(); 
</script></head>
<body ></body>
</html>

Call this page: CartData.html

3- Rename the first page of your site or cart page to: body.html

4- Here is the new nopcart.js file:
Code: Select all
//=====================================================================||
//               NOP Design JavaScript Shopping Cart                   ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||

//---------------------------------------------------------------------||
//                       Global Options                                ||
//                      ----------------                               ||
// Shopping Cart Options, you can modify these options to change the   ||
// the way the cart functions.                                         ||
//                                                                     ||
// Language Packs                                                      ||
// ==============                                                      ||
// You may include any language pack before nopcart.js in your HTML    ||
// pages to change the language.  Simply include a language pack with  ||
// a script src BEFORE the <SCRIPT SRC="nopcart.js">... line.          ||
//  For example: <SCRIPT SRC="language-en.js">                         ||
//                                                                     ||
// Options For Everyone:                                               ||
// =====================                                               ||
// * MonetarySymbol: string, the symbol which represents dollars/euro, ||
//   in your locale.                                                   ||
// * DisplayNotice: true/false, controls whether the user is provided  ||
//   with a popup letting them know their product is added to the cart ||
// * DisplayShippingColumn: true/false, controls whether the managecart||
//   and checkout pages display shipping cost column.                  ||
// * DisplayShippingRow: true/false, controls whether the managecart   ||
//   and checkout pages display shipping cost total row.               ||
// * DisplayTaxRow: true/false, controls whether the managecart        ||
//   and checkout pages display tax cost total row.                    ||
// * TaxRate: number, your area's current tax rate, ie: if your tax    ||
//   rate was 7.5%, you would set TaxRate = 0.075                      ||
// * TaxByRegion: true/false, when set to true, the user is prompted   ||
//   with TaxablePrompt to determine if they should be charged tax.    ||
//   In the USA, this is useful to charge tax to those people who live ||
//   in a particular state, but no one else.                           ||
// * TaxPrompt: string, popup message if user has not selected either  ||
//   taxable or nontaxable when TaxByRegion is set to true.            ||
// * TaxablePrompt: string, the message the user is prompted with to   ||
//   select if they are taxable.  If TaxByRegion is set to false, this ||
//   has no effect. Example: 'Arizona Residents'                       ||
// * NonTaxablePrompt: string, same as above, but the choice for non-  ||
//   taxable people.  Example: 'Other States'                          ||
// * MinimumOrder: number, the minium dollar amount that must be       ||
//   purchased before a user is allowed to checkout.  Set to 0.00      ||
//   to disable.                                                       ||
// * MinimumOrderPrompt: string, Message to prompt users with when     ||
//   they have not met the minimum order amount.                       ||
//                                                                     ||
// Payment Processor Options:                                          ||
// ==========================                                          ||
// * PaymentProcessor: string, the two digit payment processor code    ||
//   for support payment processor gateways.  Setting this field to    ||
//   anything other than an empty string will override your OutputItem ||
//   settings -- so please be careful when receiving any form data.    ||
//   Support payment processor gateways are:                           ||
//    * Authorize.net (an)                                             ||
//    * Worldpay      (wp)                                             ||
//    * LinkPoint     (lp)
//                                                                     ||
// Options For Programmers:                                            ||
// ========================                                            ||
// * OutputItem<..>: string, the name of the pair value passed at      ||
//   checkouttime.  Change these only if you are connecting to a CGI   ||
//   script and need other field names, or are using a secure service  ||
//   that requires specific field names.                               ||
// * AppendItemNumToOutput: true/false, if set to true, the number of  ||
//   each ordered item will be appended to the output string.  For     ||
//   example if OutputItemId is 'ID_' and this is set to true, the     ||
//   output field name will be 'ID_1', 'ID_2' ... for each item.       ||
// * HiddenFieldsToCheckout: true/false, if set to true, hidden fields ||
//   for the cart items will be passed TO the checkout page, from the  ||
//   ManageCart page.  This is set to true for CGI/PHP/Script based    ||
//   checkout pages, but should be left false if you are using an      ||
//   HTML/Javascript Checkout Page. Hidden fields will ALWAYS be       ||
//   passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script  ||
//---------------------------------------------------------------------||

//Options for Everyone:
MonetarySymbol        = '';
DisplayNotice         = true;
DisplayShippingColumn = false;
DisplayShippingRow    = false;
DisplayTaxRow         = true;
TaxRate               = 0.175;
TaxByRegion           = true;
TaxPrompt             = 'For tax purposes, please select if you are a subjected to Local Tax  before continuing';
TaxablePrompt         = 'Subject Tax.';
NonTaxablePrompt      = 'Exempt from Tax.';
MinimumOrder          = 1.00;
MinimumOrderPrompt    = 'Your order is below our minimum order, please order more before checking out.';

//Payment Processor Options:
PaymentProcessor      = '';

//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;


//=====================================================================||
//---------------------------------------------------------------------||
//    YOU DO NOT NEED TO MAKE ANY MODIFICATIONS BELOW THIS LINE        ||
//---------------------------------------------------------------------||
//=====================================================================||


//---------------------------------------------------------------------||
//                      Language Strings                               ||
//                     ------------------                              ||
// These strings will not be used unless you have not included a       ||
// language pack already.  You should NOT modify these, but instead    ||
// modify the strings in language-**.js where ** is the language pack  ||
// you are using.                                                      ||
//---------------------------------------------------------------------||
if ( !bLanguageDefined ) {
   strSorry  = "I'm Sorry, your cart is full, please proceed to checkout.";
   strAdded  = " added to your shopping cart.";
   strRemove = "Click 'Ok' to remove this product from your shopping cart.";
   strILabel = "Product Id";
   strDLabel = "Description";
   strQLabel = "Quantity";
   strPLabel = "Price";
   strSLabel = "Shipping";
   strRLabel = "Remove From Cart";
   strRButton= "Remove";
   strSUB    = "SUBTOTAL";
   strSHIP   = "SHIPPING";
   strTAX    = "V.A.T.";
   strTOT    = "TOTAL";
   strErrQty = "Invalid Quantity.";
   strNewQty = 'Please enter new quantity:';
   strCEmpty = 'Your cart is empty';
   bLanguageDefined = true;
}

//---------------------------------------------------------------------||
// FUNCTION:    Read / write Cart data                                 ||
// PARAMETERS:  None                                                   ||
// RETURNS:     Cart content                                           ||
// PURPOSE:     Manages the Cart content onto the hidden frame         ||
//---------------------------------------------------------------------||
 
function GetCart(ArrNum) {
  return parent.CartData.CartArray[ArrNum]
}

function SetCart(ArrNum,CartVal) {
  parent.CartData.CartArray[ArrNum] = CartVal
}

function NumCart() {
  return parent.CartData.CartArray.length;
}

function DelCart(ArrNum) {
  parent.CartData.CartArray.splice(ArrNum,1)
}

function CleanCart() {
  parent.CartData.CartArray.splice(0,parent.CartData.CartArray.length);
}

//---------------------------------------------------------------------||
// FUNCTION:    CKquantity                                             ||
// PARAMETERS:  Quantity to                                            ||
// RETURNS:     Quantity as a number, and possible alert               ||
// PURPOSE:     Make sure quantity is represented as a number          ||
//---------------------------------------------------------------------||
 function CKquantity(checkString) {
   var strNewQuantity = "";
   for ( i = 0; i < checkString.length; i++ ) {
      ch = checkString.substring(i, i+1);
      if ( (ch >= "0" && ch <= "9") || (ch == '.') )
         strNewQuantity += ch;
   }

   if ( strNewQuantity.length < 1 )
      strNewQuantity = "1";

   return(strNewQuantity);
}

//---------------------------------------------------------------------||
// FUNCTION:    AddToCart                                              ||
// PARAMETERS:  Form Object                                            ||
// RETURNS:     Value 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 = NumCart();
   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 = 0; i < iNumberOrdered; i++ ) {
      database = "";
      database = GetCart(i);

      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;
         SetCart(i,dbUpdatedOrder);
         notice = strQUANTITY + " " + strNAME + strAdded;
         break;
      }
   }


   if ( !bAlreadyInCart ) {
 
         dbUpdatedOrder = strID_NUM    + "|" +
                          strQUANTITY  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strADDTLINFO;

        SetCart(iNumberOrdered,dbUpdatedOrder);

         notice = strQUANTITY + " " + strNAME + strAdded;
   }

   if ( DisplayNotice )
      alert(notice);

NumberThisItem(thisForm)
return false

}

//---------------------------------------------------------------------||
// FUNCTION:    MoneyFormat                                            ||
// PARAMETERS:  Number to be formatted                                 ||
// RETURNS:     Formatted Number                                       ||
// PURPOSE:     Reformats Dollar Amount to #.## format                 ||
//---------------------------------------------------------------------||
function moneyFormat(input) {
   var dollars = Math.floor(input);
   var tmp = new String(input);

   for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
      if ( tmp.charAt(decimalAt)=="." )
         break;
   }

   var cents  = "" + Math.round(input * 100);
   cents = cents.substring(cents.length-2, cents.length)
           dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;

   if ( cents == "0" )
      cents = "00";

   return(dollars + "." + cents);
}

//---------------------------------------------------------------------||
// FUNCTION:    RemoveFromCart                                         ||
// PARAMETERS:  Order Number to Remove                                 ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Removes an item from a users shopping cart             ||
//---------------------------------------------------------------------||
function RemoveFromCart(RemOrder) {
      DelCart(RemOrder)
location.href=location.href;
}

//---------------------------------------------------------------------||
// FUNCTION:    ChangeQuantity                                         ||
// PARAMETERS:  Order Number to Change Quantity                        ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Changes quantity of an item in the shopping cart       ||
//---------------------------------------------------------------------||
function ChangeQuantity(OrderItem,NewQuantity) {
   if ( isNaN(NewQuantity)) {
      alert( strErrQty );
} else {

      NewOrder = "Order." + OrderItem;
      database = "";
      database = GetCart(OrderItem)

      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 );

      dbUpdatedOrder = fields[0] + "|" +
                       NewQuantity + "|" +
                       fields[2] + "|" +
                       fields[3] + "|" +
                       fields[4] + "|" +
                       fields[5];
      SetCart(OrderItem,dbUpdatedOrder);
      location.href=location.href;     
 
   }
}


//---------------------------------------------------------------------||
// FUNCTION:    GetFromCart                                            ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page          ||
//              **DEPRECATED FUNCTION, USE ManageCart or Checkout**    ||
//---------------------------------------------------------------------||
function GetFromCart( fShipping ) {
   ManageCart( );
}


//---------------------------------------------------------------------||
// FUNCTION:    RadioChecked                                           ||
// PARAMETERS:  Radio button to check                                  ||
// RETURNS:     True if a radio has been checked                       ||
// PURPOSE:     Form filling validation                                 ||
//---------------------------------------------------------------------||
function RadioChecked( radiobutton ) {
   var bChecked = false;
   var rlen = radiobutton.length;
   for ( i=0; i < rlen; i++ ) {
      if ( radiobutton[i].checked )
         bChecked = true;
   }   
   return bChecked;
}


//---------------------------------------------------------------------||
// FUNCTION:    QueryString                                            ||
// PARAMETERS:  Key to read                                            ||
// RETURNS:     value of key                                           ||
// PURPOSE:     Read data passed in via GET mode                       ||
//---------------------------------------------------------------------||
QueryString.keys = new Array();
QueryString.values = new Array();
function QueryString(key) {
   var value = null;
   for (var i=0;i<QueryString.keys.length;i++) {
      if (QueryString.keys[i]==key) {
         value = QueryString.values[i];
         break;
      }
   }
   return value;
}

//---------------------------------------------------------------------||
// FUNCTION:    QueryString_Parse                                      ||
// PARAMETERS:  (URL string)                                           ||
// RETURNS:     null                                                   ||
// PURPOSE:     Parses query string data, must be called before Q.S.   ||
//---------------------------------------------------------------------||
function QueryString_Parse() {
   var query = window.location.search.substring(1);
   var pairs = query.split("&"); for (var i=0;i<pairs.length;i++) {
      var pos = pairs[i].indexOf('=');
      if (pos >= 0) {
         var argname = pairs[i].substring(0,pos);
         var value = pairs[i].substring(pos+1);
         QueryString.keys[QueryString.keys.length] = argname;
         QueryString.values[QueryString.values.length] = value;
      }
   }
}


//---------------------------------------------------------------------||
// 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 = NumCart();
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

   if ( bDisplay )
      strOutput = "<table id=\"myCartTable\"><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 = 0; i < iNumberOrdered; i++ ) {
      database = GetCart(i);

      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 );          // 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]) + "/ea</td>";

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<td>"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</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:    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:    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 = NumCart();
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

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

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

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

      database = "";
      database = GetCart(i);

      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 );          // 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]) + "/ea</td>";

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

         strOutput += "</tr>";
      }

      if ( AppendItemNumToOutput ) {
         strFooter = i;
      } else {
         strFooter = "";
      }
      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>";

     
      if ( PaymentProcessor == 'an') {
         //Process this for Authorize.net WebConnect
         strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">";
         strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">";
         strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">";
         strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
      } else if ( PaymentProcessor == 'wp') {
         //Process this for WorldPay
         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
         strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
      } else if ( PaymentProcessor == 'lp') {
         //Process this for LinkPoint         
         strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">";
         strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
         strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
      } else {
         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)) + "\">";
      }
   }

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

//=====================================================================||
//               END NOP Design SmartPost Shopping 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 = NumCart();
if ( iNumberOrdered == null )
iNumberOrdered = 0;

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

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

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 ); // 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: 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 = NumCart();
if ( iNumberOrdered == null )
iNumberOrdered = 0;

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

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

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 ); // 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: Cart_is_empty                                             ||
// PARAMETERS: none                                                    ||
// RETURNS: Total true if cart is empty, false otherwise               ||
// PURPOSE: Aesthetics                                                 ||
//---------------------------------------------------------------------||
function Cart_is_empty( ) {
   iNumInCart = NumCart();
   if ( iNumInCart == null ) iNumInCart = 0;
   if ( iNumInCart == 0 ) return true;
   return false;
}

//===================================================================================

5- And last update your checkout.pl/php to allow for the extra capacity of your cart in relation to the Email and CVS sections.

ENJOY! :D
p.s I have include an updated version of the nopcart_css demo site called nopcart_css_unlimited which includes my updated version of the checkout.pl with 200 product lines.
I am not so good at perl but maybe someone could come up with a loop feature in the product sections to avoid having to predict how many product lines you will require?
grenooye
Guru
 
Posts: 11
Joined: Fri Sep 12, 2008 8:27 am

Re: 500+ items in the basket

Postby Koibito » Wed Oct 08, 2008 12:31 pm

Cool! This is very nice. Thanks a lot. I'll see if I can come up with a modified version of the Perl script as soon as I get this to work.
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Re: 500+ items in the basket

Postby Stefko » Wed Oct 08, 2008 10:40 pm

Isn't it a pain to reinvent the wheel......

I have decided to make this snippet available from StaticCart, (Modified for NOPCart), this will loop thru up to the defined capacity.

Code: Select all
   print MAIL "====================================== \n";
$capacity = 200; // Set Maximum Cart Allowed
   for($y=1;$y<=$capacity;$y++){
      $thename="NAME_$y";
         if(length(${$thename})>3){
         $num++;
      }
   }
   foreach($x=1; $x<=$num; $x++){
      $qnt="QUANTITY_$x";
      $prce="PRICE_$x";
      $ide="ID_$x";
      $naam="NAME_$x";
      $adlinfo="ADDTLINFO_$x";
      ${$naam}=~ s/\n//g;
   print MAIL "Qty: ${$qnt}   \nItem No: ${$ide}   \nDescpition: ${$naam}   \nAddtl. Info: ${$adlinfo}   \nPrice: \$${$prce} \n\n";
   }
   print MAIL "====================================== \n";


Enjoy
KFL Technologies
Web-Enabled Solutions
e-Commerence Solutions
Stefko
Contributor / Guru
 
Posts: 833
Joined: Wed Sep 18, 2002 1:11 am
Location: Wichita, KS

Re: 500+ items in the basket

Postby Tom4us » Thu Oct 09, 2008 6:17 am

I hope you put the same thing for PHP script. Not very good at it . Thanks for everything Stefko, Koibito, bossturbo,NetteDesign and everybody that contributed.
Tom4us
Guru
 
Posts: 55
Joined: Fri Feb 07, 2003 11:02 am
Location: Kenya

Re: 500+ items in the basket

Postby grenooye » Wed Jul 01, 2009 1:01 pm

I was having problems with the loop posted above as it wasn't reading the values of the variables, after a tedious debugging session I found the required alteration to the code to be as follows:

print MAIL "====================================== \n";
$capacity = 200; // Set Maximum Cart Allowed
for($y=1;$y<=$capacity;$y++){
$thename=${"NAME_$y"};
if($thename){
$num++;
}
}
foreach($x=1; $x<=$num; $x++){
$qnt=${"QUANTITY_$x"};
$prce=${"PRICE_$x"};
$ide=${"ID_$x"};
$naam=${"NAME_$x"};
$adlinfo=${"ADDTLINFO_$x"};
${$naam}=~ s/\n//g;
print MAIL "Qty: $qnt \nItem No: $ide \nDescpition: $naam \nAddtl. Info: $adlinfo \nPrice: \$$prce \n\n";
}
print MAIL "====================================== \n";

This will read the variable values.
Cheers
grenooye
Guru
 
Posts: 11
Joined: Fri Sep 12, 2008 8:27 am

Re: 500+ items in the basket

Postby angel » Fri May 21, 2010 4:56 pm

bossturbo what kind of changes will i have to make to my checkout.php page, if i use the code you provided?
angel
WebMaster
 
Posts: 19
Joined: Thu Feb 25, 2010 10:28 pm

Re: 500+ items in the basket

Postby graphics » Fri Mar 27, 2015 12:44 pm

Ok GURU's, you all know exactly what you're doing and where to put the snippet, but for the rest of us...could you please tell where to put this in our .pl files? :D I've read through the comments many times over and unless I'm missing something, (which is always possible, LMBO) there's no mention as to "where in the .pl file" to place it. I've found where the "print" section begins and ends so do I place before, after, or instead? Or maybe at the main bottom before it all closes? Please, someone instruct? :oops:
graphics
WebMaster
 
Posts: 50
Joined: Fri Oct 06, 2006 5:01 am


Return to Modifications

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron