'); } var g_checkFields = new Array('Key', 'Name', 'Description', 'Price', 'Weight'); function checkItemInfo() { for (var i = 0; i < g_checkFields.length; i++) { var fld = g_checkFields[i]; if (g_itemInfo[fld] == undefined) g_itemInfo[fld] = ''; } if (g_itemInfo['Weight'] != '') { var tmp = formatDouble(g_itemInfo['Weight']); if (tmp != undefined) g_itemInfo['Weight'] = tmp; } if (g_itemInfo['Price'] != '') { var tmp = formatCurrency(g_itemInfo['Price']); if (tmp != undefined) g_itemInfo['Price'] = tmp; } } function saveItemInfo() { var input = GetBDO('Locale', getMerchantLocale(), 'Type', 0); var output = GetBDO(); if (g_itemID != '') { // this is an existing item input['ItemID'] = g_itemID; } else { var key = GetFormValue('Key'); if (key == '') return false; input['Key'] = key; // this is a new item -- provide default values for // fields not prompted for input['PricePrecision'] = getDefaultPrecision(); input['PriceType'] = 0; input['TAX_CATEGORY_NODE_ID'] = 201; input['FractQty'] = 0; input['OutOfStock'] = 0; } var page = new Array('ItemName','item_PictureFile','Description','Price','Weight'); var db = new Array('Name','PictureFile','Description','Price','Weight'); for (var i = 0; i < page.length; i++) { var tmp = GetFormValue(page[i]); if (tmp == '') continue; var fld = db[i]; input[fld] = tmp; } if (input['Weight'] != undefined) { var tmp = stripCommas(input['Weight']); tmp = parseFloat(tmp); if (!isNaN(tmp)) input['Weight'] = tmp; } if (input['Price'] != undefined) { var tmp = stripCommas(input['Price']); tmp = stripCurrency(tmp); tmp = parseFloat(tmp); if (!isNaN(tmp)) input['Price'] = tmp; } var cat = GetFormValue('Category'); if (cat == '') cat = 'none'; else { cat = parseInt(cat); if (isNaN(cat)) cat = 'none'; } // first get rid of the old nodes, if necessary if (g_itemID != '') doAction('CAT_DELETEITEMNODES', 'ItemID', g_itemID); // here is where the new item should be added, and g_itemID set ProcessRequest('ITEM_MODIFY', input, output); if (output['ItemID'] != undefined) { var tmp = parseInt(output['ItemID']); if (!isNaN(tmp)) g_itemID = tmp; } // then add in the new node, if necessary if (cat != 'none') { var cat_in = GetBDO('ItemID', g_itemID, 'Node0001', cat); doAction('CAT_SETITEMNODES', cat_in); } } function main() { if (g_task == 'save') { // save item info, and close the window saveItemInfo(); MakeWindowClose(); g_task = 'edit'; } if (g_task == 'edit') { if (g_itemID == '') return; // load item info var input = GetBDO('ItemID', g_itemID, 'Locale', getMerchantLocale()); ProcessRequest('ITEM_GETALLFIELDS', input, g_itemInfo); // load category list var cats = doActionBDO('CAT_GETITEMNODES', 'ItemID', g_itemID); if (cats != undefined && IsBDO(cats)) g_itemCategories = cats.GetValues(); } checkItemInfo(); } main();

Add or Edit Item
Edit text in white boxes.   * = required field

'); writeln(''); } '); writeln('');
* SKU:
* Name:
  Image: '); writeln(''); writeln('Select Image  
  Description:
* Price:
  Category:

Online Help Cancel Save