I tried to have the mini shopping cart (in javascript) show up below my site logo (which I edit in page header and footer), with the code below. Problem is, it won't work. It is visible, but it says there are 0 items in the cart, no matter what I have in it. It works fine to click on, and it will take me to my shopping cart. But other than that..
I asked my host for serial number for the shopping cart, as it should be included in the script, and they gave me the number which looks like the example serial that shopsite uses. The serial number is not visible in my back office due to security reasons (refering to the host of my site).
Anyone knows what could be wrong here?
Also, if anyone knows how/where to change the text (translate it into my preferred language) for "items", please let me know.
- Code: Select all
<img src="http://sivstorhaug.powweb.com/store/media/logo.jpg"><br>
<script language="javascript">
/**** Mini Cart Subtotal Display ****/
/**** REPLACE THE VALUES IN THESE LINES ****/
var serialnum="0000007011";
var cartURL="http://shopsite.powweb.com/ss8.1/sc/order.cgi?storeid=*26c057b275efbc4834c7b9018fb6e005594fbc9e93&function=show";
var textColor="black";
var backgroundColor="transparent";
var showCart="yes"; // only "yes" or "no"
var cartColor="black"; // only "black" or "white"
var textAlign="left"; // only "left" "right" or "center"
/**** DON'T CHANGE ANYTHING BELOW HERE ****/
var linkColor=textColor;
var cookies=document.cookie; //read in all cookies
var start = cookies.indexOf("ss_cart_" + serialnum + "=");
var cartvalues = "";
var linecount = 0;
var start1;
var end1;
var tmp;
// Start Output
document.write("<div style=\"color:" + textColor + ";");
document.write("background-color:" + backgroundColor + ";");
document.write("text-align:" + textAlign + ";");
document.write("font-family: Verdana, Arial, Helvetica, sans-serif;");
document.write("font-size: 8pt;");
document.write("\">\n");
if (showCart == "yes")
{
document.write("<a href=\"");
document.write(cartURL + "\"");
document.write(">");
document.write("<img src=\"./media/themesmedia/cart-" + cartColor + ".gif\" border=\"0\" align=\"top\">");
document.write("</a> ");
}
if (start == -1) //No cart cookie
{
document.write("<a href=\"" + cartURL + "\" style=\"color:" + linkColor + "\">");
document.write("0 Items");
document.write("</a> ");
document.write("</div>\n");
}
else //cart cookie is present
{
start = cookies.indexOf("=", start) +1;
var end = cookies.indexOf(";", start);
if (end == -1)
{
end = cookies.length;
}
cartvalues = unescape(cookies.substring(start,end)); //read in just the cookie data
start = 0;
while ((start = cartvalues.indexOf("|", start)) != -1)
{
start++;
end = cartvalues.indexOf("|", start);
if (end != -1)
{
linecount++;
if (linecount == 2) // Total Quantity of Items
{
tmp = cartvalues.substring(start,end);
colon = tmp.indexOf(":", 0);
document.write("<a href=\"" + cartURL + "\" style=\"color:" + linkColor + "\">");
document.write(tmp.substring(colon+1,end - start));
if ((tmp.substring(colon+1,end - start)) == 1 )
{
document.write(" Item");
}
else
{
document.write(" Items");
}
document.write(": ");
}
if (linecount == 3) // Product Subtotal
{
tmp = cartvalues.substring(start,end);
colon = tmp.indexOf(":", 0);
document.write(tmp.substring(colon+1,end - start));
document.write("</a>");
}
start = end;
}
else
break;
}
} // end while loop
//close minicart HTML
document.write("</div>\n");
</script>