If you already have a custom page template that you're using in your ShopSite Pro store, you can easily add the mini cart by just copying some code from this page and pasting it into your template. After copying in the code, you can optionally set some values to change the colors in the cart. You may want to print out these instructions so that you are not having to constantly switch windows on your screen to read them.
1. Copy and Paste the Code
In this step, you select a mini cart style and copy and paste the code for that style into a text editor.
ItemCount Style
#### YOU CAN CHANGE THESE VALUES IF NEEDED #### [-- VAR.ShowCart "yes" --][-- VAR.MiniCartColor "black" --] #### DON'T CHANGE ANYTHING BELOW HERE #### <script type="text/javascript"> var cookies=document.cookie; //read in all cookies var start = cookies.indexOf("ss_cart_[-- STORE_Serial_Number --]=");var cartvalues = "";var linecount = 0;var start1;var end1;var tmp; // Start Output [-- IF VAR.ShowCart "yes" --] document.write("<a href=\"[-- SHOPPING_CART_URL --]\">"); document.write("<img src=\"[-- OUTPUT_DIRECTORY_URL --]/media/themesmedia/cart-[-- VAR.MiniCartColor --].gif\" border=\"0\" name=\"cart\" align=\"top\">"); document.write("<\/a> "); [-- END_IF --] if (start == -1) //No cart cookie { document.write("<a href=\"[-- SHOPPING_CART_URL --]\">0 [-- STORE.Items --]<\/a>"); } 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=\"[-- SHOPPING_CART_URL --]\">"); document.write(tmp.substring(colon+1,end - start)); if ((tmp.substring(colon+1,end - start)) == 1 ){document.write(" [-- STORE.Item --]");} else {document.write(" [-- STORE.Items --]");} document.write("<\/a>"); } start = end; } else break; } } </script>
Subtotal Style
#### YOU CAN CHANGE THESE VALUES IF NEEDED #### [-- VAR.ShowCart "yes" --][-- VAR.MiniCartColor "black" --] #### DON'T CHANGE ANYTHING BELOW HERE #### <script type="text/javascript"> var cookies=document.cookie; //read in all cookies var start = cookies.indexOf("ss_cart_[-- STORE_Serial_Number --]=");var cartvalues = "";var linecount = 0;var start1;var end1;var tmp; // Start Output [-- IF VAR.ShowCart "yes" --] document.write("<a href=\"[-- SHOPPING_CART_URL --]\"><img src=\"[-- OUTPUT_DIRECTORY_URL --]/media/themesmedia/cart-[-- VAR.MiniCartColor --].gif\" border=\"0\" name=\"cart\" align=\"top\"><\/a> "); [-- END_IF --] if (start == -1) //No cart cookie { document.write("<a href=\"[-- SHOPPING_CART_URL --]\">"); document.write("0 [-- STORE.Items --]"); document.write("<\/a> "); } 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=\"[-- SHOPPING_CART_URL --]\">"); document.write(tmp.substring(colon+1,end - start)); if ((tmp.substring(colon+1,end - start)) == 1 ){document.write(" [-- STORE.Item --]");} else{document.write(" [-- STORE.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; } } </script>
Summary Style
#### YOU CAN CHANGE THESE VALUES IF NEEDED #### [-- VAR.ShowCart "no" --][-- VAR.MiniCartColor "black" --] #### DON'T CHANGE ANYTHING BELOW HERE #### <script type="text/javascript"> var cookies=document.cookie; //read in all cookies var start = cookies.indexOf("ss_cart_[-- STORE_Serial_Number --]=");var cartvalues = "";var linecount = 0;var start1;var end1;var tmp; // Start Output [-- IF VAR.ShowCart "yes" --] document.write("<a href=\"[-- SHOPPING_CART_URL --]\"><img src=\"[-- OUTPUT_DIRECTORY_URL --]/media/themesmedia/cart-[-- VAR.MiniCartColor --].gif\" border=\"0\" name=\"cart\" align=\"top\"><\/a> "); [-- END_IF --] document.write("<a href=\"[-- SHOPPING_CART_URL --]\">"); document.write("[-- STORE.SC_YourShoppingCart --]"); document.write("<\/a>"); if (start == -1) //No cart cookie { } 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("<br>[-- STORE.Contains --] <b>"); document.write(tmp.substring(colon+1,end - start)); document.write("<\/b>"); if ((tmp.substring(colon+1,end - start)) == 1 ){document.write(" [-- STORE.Item --]");} else {document.write(" [-- STORE.Items --]");} } if (linecount == 3) // Product Subtotal { tmp = cartvalues.substring(start,end); colon = tmp.indexOf(":", 0); document.write("<br>[-- STORE.Subtotal --]: <b>"); document.write(tmp.substring(colon+1,end - start)); document.write("<\/b>"); } start = end; } else break; } } </script>
Detail Style
#### YOU CAN CHANGE THESE VALUES IF NEEDED #### [-- VAR.ShowCart "no" --][-- VAR.MiniCartColor "black" --] #### DON'T CHANGE ANYTHING BELOW HERE #### <script type="text/javascript"> var cookies=document.cookie; //read in all cookies var start = cookies.indexOf("ss_cart_[-- STORE_Serial_Number --]=");var cartvalues = "";var linecount = 0;var start1;var end1;var tmp; // Start Output document.write("<table>"); document.write("<tr>"); document.write("<th colspan=\"3\" align=\"center\">"); [-- IF VAR.ShowCart "yes" --] document.write("<a href=\"[-- SHOPPING_CART_URL --]\">"); document.write("<img src=\"[-- OUTPUT_DIRECTORY_URL --]/media/themesmedia/cart-[-- VAR.MiniCartColor --].gif\" border=\"0\" name=\"cart\" align=\"top\">"); document.write("<\/a> "); [-- END_IF --] document.write("<a href=\"[-- SHOPPING_CART_URL --]\">"); document.write("[-- STORE.SC_YourShoppingCart --]"); document.write("<\/a>"); document.write("<\/th><\/tr>"); if (start == -1) //No cart cookie { document.write("<\/table>"); } 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 == 3) // Product Subtotal { start1 = start; end1 = end; document.write("<tr><td>Qty<\/td>"); document.write("<td align=\"center\">Product<\/td>"); document.write("<td align=\"center\">Price</td><\/tr>"); } if (linecount > 3) // individual products { tmp = cartvalues.substring(start,end); colon = tmp.indexOf(":", 0); document.write("<tr>"); document.write("<td>"); document.write(tmp.substring(0,colon)); document.write("<\/td><td>"); colon2 = tmp.indexOf(":", colon+1); document.write(tmp.substring(colon2+1,end - start)); document.write("<\/td><td align=\"right\">"); document.write(tmp.substring(colon+1,colon2)); document.write("<\/td><\/tr>"); } start = end; } else { break; } } // end while loop //close minicart HTML document.write("<tr>"); document.write("<td colspan=\"2\" align=\"right\">Subtotal<\/td>"); document.write("<td align=\"right\">"); tmp = cartvalues.substring(start1,end1); colon = tmp.indexOf(":", 0); document.write(tmp.substring(colon+1,end1 - start1)); document.write("<\/td>"); document.write("<\/tr>"); document.write("<\/table>"); } </script>
2. Set Colors and Options
The default settings in the mini cart code use the page link color and a transparent background colors. The ItemCount and Subtotal layouts also display a small black graphic of a shopping cart. You can follow these steps to change these colors, or you can skip this part to use the default colors.
3. Paste the Code into Your Template
Now that you've copied the code and customized it, you're ready to paste it into your custom page template. (You may want to save it as an "include" file, which looks cleaner but has the same end result; see the next section for instructions on how to do that.)
4. Saving Your Mini Cart Code as an Include File
Custom template "include" files make it easy to modularize your templates, which can result in cleaner code and reusable components. By saving your mini cart code as an include file, it will be easier to make changes to that code and your page template will be easier to read.
If you have some non-ShopSite created pages that are still at the same domain, or if you want to paste the minicart directly into a text field instead of in your template, you can use non-template populated JavaScript for the minicart.