Scusate la mia ignoranza, ma purtroppo non ne posso fare a meno.
Questo script qua sotto è uno script che crea un'estensione di dreamweaver per gestire il carrello dell'ecommerce.
Lo script funziona perfettamente solo che necessito di modificare il valore chiamato "ShippingCost".
Attualmente questo valore è 0 e mi rimane sempre tale....
Ad un certo punto del codice c'è questa scritta "this.ShippingCost = 0.00" ho provato li a mettere un valore per esempio 10.00 ma il risultato è sempre zero.
Per quel poco che ahimè so e ci capisco dovrebbe leggere i valori da un cookie???
Sapete aiutarmi e dirmi come posso mettere il valore 10 allo shipping cost?
Grazie a tutti.....
<script language="javascript" runat="server">
function UltraCartVB(Name, xmlPath)
{
return new UltraCart(Name, xmlPath);
}
// Constructor
function UltraCart(Name, xmlPath)
{
this.Name = Name;
// Main Cart Column Constants
this.PRODUCTID = "ProductID";
this.QUANTITY = "Quantity";
this.PRICE = "Price";
this.TOTAL = "Total";
this.COOKIEBLOCKDEL = "#B#";
this.COOKIECOLDEL = "#C#"
this.COOKIEROWDEL = "#R#"
/*
// Line Item Discount Constants
this.DISCOUNTRATE = "DiscountRate";
this.DISCOUNTTHRESHOLD = "DiscountThreshold";
this.DISCOUNTVALUE = "DiscountValue";
this.DISCOUNTTYPE = "DiscountType";
// Group Discount Constants
this.GROUPDISCOUNTCATEGORY = "GroupDiscCategory";
this.GROUPDISCOUNTRATE = "GroupDiscRate";
this.GROUPDISCOUNTTHRESHOLD = "GroupDiscThreshold";
this.GROUPDISCOUNTVALUE = "GroupDiscValue";
this.GROUPDISCOUNTTYPE = "GroupDiscType";
*/
this.ShippingCost = 0.00;
this.ShippingMethod = "";
this.TaxStateProvince = 0.00;
this.TaxCountry = 0.00;
this.TaxLocalePostal = 0.00;
this.SumTax = 0.00;
this.DiscountGroup = 0.00;
this.DiscountLineItem = 0.00;
this.Discount = 0.00;
this.SumDiscount = 0.00;
this.Subtotal = 0.00;
this.GrandTotal = 0.00;
// Load Cart Definitions
var objXMLDoc;
try
{
objXMLDoc = Server.CreateObject("Msxml2.DOMDocument"); // Msxml2.DOMDocument.4.0 XML v4 call
}
catch(e)
{
this.Assert(false , "You need XML services installed on this server...See http:\/\/www.microsoft.com/xml for more information..." );
}
objXMLDoc.async = false;
objXMLDoc.resolveExternals = false;
objXMLDoc.load(xmlPath);
this.Assert(!objXMLDoc.parseError.errorCode , "Constructor: " + objXMLDoc.parseError.reason);
// Load Cart Settings
var objNodeList = objXMLDoc.documentElement.getElementsByTagName("Ca rt");
for( var iCol=0; iCol < objNodeList.length; iCol++)
{
if(objNodeList[iCol].getAttribute("name") == this.Name)
{
var objXMLDocCart = objNodeList[iCol];
break;
}
}
this.CookieLifeTime = parseInt(objXMLDocCart.getAttribute("CookieLifeTim e"));
this.useComputeTotalsAdvanced = objXMLDocCart.getAttribute("UseComputeTotalsAdvanc ed");
Session.LCID = objXMLDocCart.getAttribute("LCID");
var nodeList = objXMLDocCart.selectSingleNode("CartColumns").chil dNodes;
this.numCols = nodeList.length;
this.CartDataTable = new Array(this.numCols);
this.cartColNames = new Array(this.numCols);
this.cartColComputed = new Array(this.numCols);
this.cartColIdentifier = new Array(this.numCols);
this.cartColType = new Array(this.numCols);
for (var i=0; i<this.numCols; i++)
{
var nodeItem = nodeList.item(i);
this.cartColNames[i] = nodeItem.getAttribute("name");
this.cartColComputed[i] = nodeItem.getAttribute("computeby");
this.cartColIdentifier[i] = nodeItem.getAttribute("identifier");
this.cartColType[i] = nodeItem.getAttribute("type");
this.CartDataTable[i] = new Array();
}
objXMLDoc = null; // free up
if (Session(this.Name) != null)
{
// load properties with exsiting values
this.CartDataTable = Session(this.Name).CartDataTable;
this.ShippingCost = Session(this.Name).ShippingCost;
this.ShippingMethod = Session(this.Name).ShippingMethod;
this.TaxStateProvince = Session(this.Name).TaxStateProvince;
this.TaxCountry = Session(this.Name).TaxCountry;
this.TaxLocalePostal = Session(this.Name).TaxLocalePostal;
this.Discount = Session(this.Name).Discount;
}
else
{
if(this.CookieLifeTime != -1) // can we restore from cookie
{
var cookieName = this.GetCookieName();
var cookieStr = Request.Cookies(cookieName)("DT");
if (cookieStr != null && String(cookieStr) != "undefined" && cookieStr != "")
{
this.ShippingCost = Request.Cookies(cookieName)("ShippingCost");
this.ShippingMethod = Request.Cookies(cookieName)("ShippingMethod");
this.TaxStateProvince = Request.Cookies(cookieName)("TaxStateProvince");
this.TaxCountry = Request.Cookies(cookieName)("TaxCountry");
this.TaxLocalePostal = Request.Cookies(cookieName)("TaxLocalePostal");
this.Discount = Request.Cookies(cookieName)("Discount");
this.DeserializeRows(cookieStr, this.COOKIECOLDEL, this.COOKIEROWDEL);
}
}
}
this.ComputeTotals();
}
UltraCart.prototype.Assert = ultracart_Assert;
function ultracart_Assert(bool, msg)
{
if (!bool)
{
Response.Write("
An error occurred in the UltraCart:
" + msg + "
");
Response.End();
}
}
UltraCart.prototype.VbToJsArray = ultracart_VbToJsArray;
function ultracart_VbToJsArray(a)
{
if (a!=null && a.length==null)
{
a = new VBArray(a);
a = a.toArray();
}
return a;
}
UltraCart.prototype.vbCartDataTable = ultracart_vbCartDataTable;
function ultracart_vbCartDataTable(iCol,iRow,setValue)
{
if(String(setValue) != "undefined")
{
this.CartDataTable[iCol][iRow] = setValue;
}
else
{
return this.CartDataTable[iCol][iRow];
}
}
UltraCart.prototype.Persist = ultracart_persist;
function ultracart_persist()
{
var sObj = new Object();
sObj.CartDataTable = this.CartDataTable;
sObj.ShippingCost = this.ShippingCost;
sObj.ShippingMethod = this.ShippingMethod;
sObj.TaxStateProvince = this.TaxStateProvince;
sObj.TaxCountry = this.TaxCountry;
sObj.TaxLocalePostal = this.TaxLocalePostal;
sObj.Discount = this.Discount;
Session(this.Name) = sObj;
var sObj = null;
if(this.CookieLifeTime != -1)
{
this.SetCookie();
}
}
UltraCart.prototype.Destroy = ultracart_destroy;
function ultracart_destroy()
{
Session.Contents.Remove(this.Name)
if(this.CookieLifeTime != -1)
{
this.DestroyCookie();
}
}
UltraCart.prototype.DeleteItemsWithNoQuantity = ultracart_DeleteItemsWithNoQuantity;
function ultracart_DeleteItemsWithNoQuantity()
{
var tmpSC = new Array(this.numCols);
for (var iCol=0; iCol<this.numCols; iCol++)
{
tmpSC[iCol] = new Array();
}
var indexQuantity = this.GetIndexOfColName(this.QUANTITY);
var iDest = 0;
for (var iRow=0; iRow<this.GetItemCount(); iRow++)
{
// Remove quantities that are zero, not a number or any specific row specified in the Query collection.
if ( isNaN(this.CartDataTable[indexQuantity][iRow]) != true)
{
if ( this.CartDataTable[indexQuantity][iRow] != 0)
{
if ( String(Request.QueryString("RemoveCartItem")) != iRow)
{
// copy row to temp table
for (var iCol=0; iCol<this.numCols; iCol++)
{
tmpSC[iCol][iDest] = this.CartDataTable[iCol][iRow];
}
iDest++;
}
}
} // isNaN
}
this.CartDataTable = tmpSC;
}
UltraCart.prototype.GetItemCount = ultracart_getitemcount;
function ultracart_getitemcount()
{
return this.CartDataTable[0].length;
}
UltraCart.prototype.ComputeItemTotalsAdvanced = ultracart_ComputeItemTotalsAdvanced;
function ultracart_ComputeItemTotalsAdvanced(iRow)
{
var re = /\[(\w*)\]/ig;
for (var iCol=0; iCol<this.numCols; iCol++)
{
var colToCompute = this.cartColComputed[iCol];
if (colToCompute != "")
{
var regArray = colToCompute.match(re);
for(var i=0; i<regArray.length; i++)
{
var colName = regArray[i].replace(/\[|\]/ig,"");
colToCompute = colToCompute.replace(regArray[i],"this.CartDataTable[" + this.GetIndexOfColName(colName) + "][iRow]")
}
this.CartDataTable[iCol][iRow] = eval(colToCompute);
}
}
}
UltraCart.prototype.ComputeItemTotals = ultracart_ComputeItemTotals;
function ultracart_ComputeItemTotals(iRow)
{
var indexQuantity = this.GetIndexOfColName(this.QUANTITY);
var qty = parseFloat(this.CartDataTable[indexQuantity][iRow]);
for (var iCol=0; iCol<this.numCols; iCol++)
{
var colToCompute = this.cartColComputed[iCol];
if (colToCompute != "")
{
indexColToCompute = this.GetIndexOfColName(colToCompute);
this.CartDataTable[indexColToCompute][iRow] = this.CartDataTable[indexColToCompute][iRow] * 1; // do this to display currency correctly for some european users
this.CartDataTable[iCol][iRow] = parseFloat(this.CartDataTable[indexColToCompute][iRow]) * qty;
}
}
}
UltraCart.prototype.UpdateTotals = ultracart_UpdateTotals;
function ultracart_UpdateTotals()
{
if(this.useComputeTotalsAdvanced)
{
for (var iRow=0; iRow< this.GetItemCount(); iRow++)
{
this.ComputeItemTotalsAdvanced(iRow);
}
}
else
{
for (var iRow=0; iRow< this.GetItemCount(); iRow++)
{
this.ComputeItemTotals(iRow);
}
}
}