<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Product Maintenance ' Product : CandyPress Store Administration ' Version : 2.5 ' Modified : February 2004 ' Copyright: Copyright (C) 2004 CandyPress.Com ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at webmaster@candypress.com '************************************************************************* Option explicit Response.Buffer = true const adminLevel = 1 %> <% 'Database dim mySQL, cn, rs, rs2 'Products dim idProduct dim description dim descriptionLong dim details dim relatedKeys dim price dim listPrice dim imageURL dim smallImageURL dim sku dim stock dim weight dim active dim hotDeal dim homePage dim fileName dim noShipCharge dim taxExempt dim reviewAllow dim reviewAutoActive dim sortOrder 'OptionsGroups dim idOptionGroup dim optionGroupDesc 'Categories dim idCategory dim categoryDesc dim idParentCategory 'Categories_Products dim idCatProd 'optionsGroupsXref dim idOptGrpProd 'DiscProd dim idDiscProd dim discAmt dim discFromQty dim discToQty dim discPerc 'productGroups dim idProdGroup dim prodGroupP dim prodGroupC 'Work Fields dim action dim i dim catArray, catArray2 '************************************************************************* 'Open Database Connection call openDB() 'Store Configuration if loadConfig() = false then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Could not load Store Configuration settings.") end if %>

Product Maintenance

<% 'Get action action = trim(Request.QueryString("action")) if len(action) = 0 then action = trim(Request.Form("action")) end if action = lCase(action) if action <> "edit" _ and action <> "del" _ and action <> "add" _ and action <> "copy" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Action Indicator.") end if 'Get idProduct if action = "edit" or action = "del" or action = "copy" then idProduct = trim(Request.QueryString("recId")) if len(idProduct) = 0 then idProduct = trim(Request.Form("recId")) end if if idProduct = "" or not isNumeric(idProduct) then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") end if idProduct = CLng(idProduct) end if 'Get Product Record if action = "edit" or action = "del" or action = "copy" then mySQL="SELECT idProduct,description,descriptionLong," _ & " relatedKeys,price,listPrice," _ & " imageURL,smallImageURL,sku," _ & " stock,weight,active,hotDeal," _ & " homePage,fileName,noShipCharge," _ & " taxExempt,reviewAllow,reviewAutoActive," _ & " sortOrder,details " _ & "FROM Products " _ & "WHERE idProduct = " & idProduct set rs = openRSexecute(mySQL) if rs.eof then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") else details = rs("details") description = rs("description") descriptionLong = rs("descriptionLong") relatedKeys = rs("relatedKeys") price = rs("price") listPrice = rs("listPrice") imageURL = rs("imageURL") smallImageURL = rs("smallImageURL") sku = rs("sku") stock = rs("stock") weight = rs("weight") active = rs("active") hotDeal = rs("hotDeal") homePage = rs("homePage") fileName = rs("fileName") noShipCharge = rs("noShipCharge") taxExempt = rs("taxExempt") reviewAllow = rs("reviewAllow") reviewAutoActive= rs("reviewAutoActive") sortOrder = rs("sortOrder") end if call closeRS(rs) end if 'Edit if action = "edit" then if len(trim(Request.QueryString("msg"))) > 0 then %> <%=Request.QueryString("msg")%>

<% end if %> Edit Product  <%call maintNavLinks()%>

<% 'Show general product info form call commonFields() %>
Product Detail
 
Product Group
<% 'Check if product is part of a Product Group mySQL="SELECT prodGroupP " _ & "FROM productGroups " _ & "WHERE prodGroupC = " & idProduct set rs = openRSexecute(mySQL) if not rs.EOF then prodGroupP = rs("prodGroupP") %> <% else prodGroupP = -1 %> <% end if call closeRS(rs) 'Display products for this Product Group mySQL="SELECT a.idProdGroup, a.prodGroupC," _ & " b.description " _ & "FROM productGroups a, products b " _ & "WHERE a.prodGroupP = " & prodGroupP & " " _ & "AND b.idProduct = a.prodGroupC " _ & "ORDER BY b.description " set rs = openRSexecute(mySQL) do while not rs.eof %> <% rs.movenext loop call closeRS(rs) %>
Click 'Remove' to remove this product from the Product Group :
Select a product to group with this product :
<%=rs("description")%> <% if rs("prodGroupC") = idProduct then %> ">Remove <% else %> ">Edit <% end if %>
Categories
<% 'Get Category Record(s) for this Product mySQL="SELECT a.idCatProd, b.idCategory, b.categoryDesc " _ & "FROM Categories_Products a " _ & "INNER JOIN Categories b " _ & "ON a.idCategory = b.idCategory " _ & "WHERE a.idProduct = " & idProduct set rs = openRSexecute(mySQL) do while not rs.eof %> <% rs.movenext loop call closeRS(rs) %>
<%=getCategoryPos(rs("idCategory"),"","N")%> ">Remove
Option Groups
<% 'Get Option Groups for this Product mySQL="SELECT a.idOptGrpProd, b.idOptionGroup, " _ & " b.optionGroupDesc " _ & "FROM optionsGroupsXref a " _ & "INNER JOIN optionsGroups b " _ & "ON a.idOptionGroup = b.idOptionGroup " _ & "WHERE a.idProduct = " & idProduct & " " _ & "ORDER BY b.sortOrder, b.optionGroupDesc " set rs = openRSexecute(mySQL) do while not rs.eof %> <% 'Get Options for Option Group mySQL = "SELECT a.idOption, a.optionDescrip, " _ & " a.priceToAdd, a.percToAdd, " _ & " (SELECT TOP 1 c.idOptionsProdEx " _ & " FROM OptionsProdEx c " _ & " WHERE c.idOption = a.idOption " _ & " AND c.idProduct = " & idProduct & ") " _ & " AS idOptionsProdEx " _ & "FROM options a, optionsXref b " _ & "WHERE a.idOption = b.idOption " _ & "AND b.idOptionGroup = " & rs("idOptionGroup") & " " _ & "ORDER BY a.sortOrder, a.optionDescrip " set rs2 = openRSexecute(mySQL) do while not rs2.eof %> <% rs2.movenext loop call closeRS(rs2) rs.movenext 'If this is the last option group record, write hidden fields and form button if rs.EOF then %> <% end if loop call closeRS(rs) %>
<%=rs("optionGroupDesc")%> (">Remove)
">    " <%if isNull(rs2("idOptionsProdEx")) then response.Write "checked"%>> <%=rs2("optionDescrip")%>
Price: <%=pCurrencySign & moneyD(rs2("priceToAdd"))%>   Perc: <%=formatNumber(rs2("percToAdd"),2)%>%
Discounts
<% 'Get Discounts for this Product mySQL="SELECT idDiscProd,discAmt," _ & " discFromQty,discToQty," _ & " discPerc " _ & "FROM DiscProd " _ & "WHERE idProduct=" & idProduct & " " _ & "ORDER BY discFromQty " set rs = openRSexecute(mySQL) do while not rs.eof %> <% rs.movenext loop call closeRS(rs) %>
Qty From Qty To Amount (ea.) Perc. (ea.)  
<%=rs("discFromQty")%> <%=rs("discToQty")%> <% if isNull(rs("discAmt")) then Response.Write "-" else Response.Write moneyD(rs("discAmt")) end if %> <% if isNull(rs("discPerc")) then Response.Write "-" else Response.Write rs("discPerc") & "%" end if %> ">Remove
<% end if 'Add and Copy if action = "add" or action = "copy" then %> Add Product  <%call maintNavLinks()%>

<% 'Show general product info form call commonFields() %>
Product Detail
<% end if 'Delete if action = "del" then %> Delete Product  <%call maintNavLinks()%>

SKU <%=SKU%>
Short Description <%=description%>
Long Description <%=descriptionLong%>
Product Details <%=details%>

<% end if if action = "edit" or action = "add" or action = "copy" then %>
Help and Instructions :
SKU - Mandatory. The SKU number/code of the Product. This may be any combination of AlphaNumeric characters.

Short Description - Mandatory. The Short Description is displayed on all Product list and detail pages. It is also saved with the Order. You may enter HTML tags into the Short Description but it's advised to stick to simple text formatting tags such as font color, size, underline, etc.

Long Description - Optional. The Long Description is displayed on Product list pages only. You may enter HTML tags into the Long Description but it's advised to stick to simple text formatting tags such as font color, size, underline, etc.

Product Details - Optional. You may enter as much text as you want into the Product Details field, including HTML tags, etc. The Product Details field is displayed on the Product Detail page only. This field is typically used to give en expanded explanation of the product itself. You may even want to enter some information regarding warranties, or links to reviews, etc.

Related Keys - Optional. This is a way to link different products together. Any keyword(s) entered into this field will be used to create a "See Related Products" link on the Product Details page. When the Customer clicks on that link, a search of the Product file will be performed, returning any Products that match the keyword(s) entered into this field. So, if you want to link together books by the same author, enter the author's name into this field. If you want to link together products with no tangible relation, enter their SKU numbers into this field. Note : Keywords must be seperated by a space, maximum of 250 characters allowed.

Price - Mandatory. The Price of the item. This is the amount which will be added to the Shopping Cart, and is used in all Order calculations, including shipping. Although the Price is mandatory, you may enter a Price of "0.00" which would effectively mean that the Product is free.

List Price - Mandatory. The List Price of the item. The amount entered into this field will be used to calculate markdowns and display a "You Save..." message on the Product pages. The List Price is usually equal to or more than the Price itself. It's not used in any Order calculations, but is used on the Order List/View pages for display purposes.

Items in Stock - Mandatory. The stock level is automatically reduced when the Order is marked as "Paid", "Complete" or "Shipped". The value in this field can also used to check if the item can still be ordered when the stock level drops below a certain number. This behaviour is determined by the "Out of stock level" store configuration setting.

Weight - Mandatory. This value is not displayed to the Customer. It's only purpose is to calculate Shipping Charges based on Product Weight. If Shipping for this item must always be based on Price, set the Weight to "0". Downloadable items should also carry a Weight of "0". Important : You MUST use the same Unit of Weight (Kilogram, Grams, Pounds, etc.) for both the Product Weight and the Shipping Rate Weight (see Shipping Maintenance). So, if you enter the Weight in "Pounds" here, you must also enter the Weight in "Pounds" on the Shipping Rates table.

Active? - Mandatory. If set to Yes, the product will be displayed in all the relevant Product lists, and the Customer will be able to Order the Product. If set to No, the Product will not be visible to the Customer.

Special Deal? - Mandatory. Indicates whether you have a Special running on this Product. It doesn't have any significant use other than grouping together Products which are currently on Sale. The value in this field does not automatically change the Price. You will still have to reduce the Price to reflect your Sale Price.

Featured? - Mandatory. Indicates whether this Item must be displayed on your Home Page or not. If there are no featured Items in the Database, the system will display whatever is in "_INCright_.asp".

Free Shipping? - Mandatory. If set to Yes, this item will not be taken into account when calculating Shipping Rates, regardless of Price or Weight. If set to No, this item will be factored into the Shipping Rate calculation. Downloadable items would typically have this field set to Yes. Or you may choose to provide Free Shipping on a Product as an incentive.

Allow Reviews? - Mandatory. If set to Yes, your customers will be able to rate this product and write a review for it.

Review Auto-Active? - Mandatory. If set to Yes, the review will automatically be activated when it's entered by a customer and will therefore be immediately viewable. If set to No, the review will be stored in the database and will only be viewable when you activate it.

Tax Exempt? - Mandatory. If set to Yes, this product will NOT be taken into account when calculating taxes for the order.

Sort Order - Optional. Numeric value that can be used to order the Products when it's displayed to the customer. If no value is supplied, the Products will be sorted by their descriptions.

Small Image - Optional. If you have a thumbnail image of the Product in your Product Images directory on your web server you can specify the filename of the image here. The system will use this filename, along with the Product Images directory path you specified in your store configuration to display the image to the user on the Product List pages. If you specify a Small Image, but not a Large Image below, the Small Image will also be displayed on the Product Detail View page.

Large Image - Optional. The same rules apply as for "Small Image" above, except that (if entered) this image will be displayed on the Product Detail View page. If Large Image is left empty, the system will display the Small Image in it's place. If you also omitted the Small Image, the Customer will see a "No Image" message. Both Small and Large Images are stored in the same directory on the web server.

File to Download - Optional. If this is a downloadable Product, you must enter the name of the file here. The file must be located in the downloads directory specified in your store configuration. Alternatively, you can enter the full URL to the file's location (ie. http://...etc.) if the file is not located in the downloads directory. The moment the order status changes to Paid, the customer will be able to download the file. Downloadable products with a price of 0.00 will be downloadable regardless of order status.

<% if action = "edit" then %> Product Groups - Products that are similar can be linked to each other via Product Groups. This way, if the customer views a product's detail, and that product belongs to a particular Product Group, the system will automatically display the other products belonging to the same Product Group on the Product Detail page. A product can belong to only one Product Group at a time.

Categories - A Product can be linked to one or more Categories. If no Categories are specified and the Product Status is Active, the Product is still accessible via the Search. If you link this Product to a Category, it will appear as part of that Category on the Product List pages in addition to being accessible through the Search. Categories need to be set up in Category Maintenance first before you can link a Product to them.

Option Groups - A Product can be linked to one or more Option Groups. If the user selects an Option which has a Price, the Option price will be added to the Product Price. You also have the option to include/exclude individual Options for a specific Product. This way you can create an Option Group called "Colors" with all the colors used in your store, and then pick only the colors from the Option Group that apply to a particular Product. Option Groups need to be set up in Option Group Maintenance before you can link them to a Product. Note that removing an Option Group from the Product does not delete the Option Group entirely, it merely removes it for the specific Product.

Discounts - You can specify discounts that will automatically be applied to the item's price when the quantity on the order matches the range specified in the "Qty From" and "Qty To" fields. You can specify an Amount or Percentage per item as a discount. If you specify a fixed amount it can not be greater than the product's price.

<% end if %>
<% end if 'Close Database Connection call closedb() 'Show/hide HTMLarea component. Due to a weird 2000 Char limit this code 'must be placed AFTER the form element containg the htmlArea field. if pHTMLarea = -1 then %> <% end if %> <% '********************************************************************* 'Display General product info form '********************************************************************* sub commonFields() %>
SKU <% if action = "edit" then %> <% else %> <% end if %> Short Description "> Long Description
(Max 250 Chars.) Product Details
(Unlimited Chars.) Related Keys "> Price List Price Items in Stock Weight Active? Special Deal? Featured? Free Shipping? Allow Reviews? Review Auto-Active? Tax Exempt? Sort Order Small Image Large Image File to Download
<% if action = "edit" then %> <% else %> <% end if %>
<% end sub '********************************************************************* 'Create Navigation Links '********************************************************************* sub maintNavLinks() %> [ List Products | New | >Edit | >Delete | >Copy | Test ] <% end sub %>