public function SetPanelSettings()
 {
     $count = 0;
     $GLOBALS['SNIPPETS']['HomeSaleProducts'] = '';
     if (GetConfig('HomeNewProducts') == 0) {
         $this->DontDisplay = true;
         return;
     }
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE p.prodsaleprice != 0 AND p.prodsaleprice < p.prodprice AND p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY RAND()\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeNewProducts'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         // Determine the price of this product
         $originalPrice = CalcRealPrice(CalcProdCustomerGroupPrice($row, $row['prodprice']), 0, 0, $row['prodistaxable']);
         $GLOBALS['OriginalProductPrice'] = CurrencyConvertFormatPrice($originalPrice);
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Workout the product description
         $desc = strip_tags($row['proddesc']);
         if (isc_strlen($desc) < 120) {
             $GLOBALS['ProductSummary'] = $desc;
         } else {
             $GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
         }
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['SNIPPETS']['HomeSaleProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeSaleProductsItem");
         if (!$GLOBALS['SNIPPETS']['HomeSaleProducts']) {
             $this->DontDisplay = true;
             return;
         }
     }
 }
 /**
  * BulkEditProductsStep2
  * Save the changes made on the bulk editing page
  *
  * @return Void
  */
 public function BulkEditProductsStep2()
 {
     if (isset($_POST["product_ids"])) {
         $product_ids = explode(",", $_POST["product_ids"]);
         // Only fetch products this user can actually edit
         $vendorRestriction = '';
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $vendorRestriction = " AND prodvendorid='" . (int) $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() . "'";
         }
         // Load the existing products
         $existingProducts = array();
         $query = "SELECT * FROM [|PREFIX|]products WHERE productid IN (" . implode(",", $GLOBALS['ISC_CLASS_DB']->Quote($product_ids)) . ") " . $vendorRestriction;
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $existingProducts[$product['productid']] = $product;
         }
         foreach ($product_ids as $product_id) {
             $prodname = $_POST["prodname_" . $product_id];
             $prodprice = DefaultPriceFormat($_POST["prodprice_" . $product_id]);
             $prodbrand = $_POST["prodbrand_" . $product_id];
             $prodbrandold = $_POST["existing_brand_" . $product_id];
             $prodbrandid = $_POST["existing_brand_id_" . $product_id];
             $prodcats = $_POST["category_" . $product_id];
             $prodcatsold = $_POST["existing_categories_" . $product_id];
             $prodfeatured = 0;
             if (isset($_POST['prodfeatured_' . $product_id])) {
                 $prodfeatured = 1;
             }
             $prodvisible = 0;
             if (isset($_POST['prodvisible_' . $product_id])) {
                 $prodvisible = 1;
             }
             $prodfreeshipping = 0;
             if (isset($_POST['prodfreeshipping_' . $product_id])) {
                 $prodfreeshipping = 1;
             }
             $prodCatsCSV = implode(",", $prodcats);
             // Calculate the new price of the product
             $existingProduct = $existingProducts[$product_id];
             $prodcalculatedprice = CalcRealPrice($prodprice, $existingProduct['prodretailprice'], $existingProduct['prodsaleprice'], $existingProduct['prodistaxable']);
             // Do we need to update the categories?
             if ($prodCatsCSV != $prodcatsold) {
                 $GLOBALS["ISC_CLASS_DB"]->DeleteQuery("categoryassociations", sprintf("WHERE productid='%d'", $product_id));
                 // Add the new category associations
                 foreach ($prodcats as $cat_id) {
                     $ca = array("productid" => $product_id, "categoryid" => $cat_id);
                     $GLOBALS['ISC_CLASS_DB']->InsertQuery("categoryassociations", $ca);
                 }
             }
             // Do we need to update the brand?
             if ($prodbrand != $prodbrandold) {
                 if ($prodbrand != "") {
                     // Is it an existing brand?
                     $bquery = sprintf("SELECT brandid FROM [|PREFIX|]brands WHERE lower(brandname)='%s'", strtolower($prodbrand));
                     $bresult = $GLOBALS["ISC_CLASS_DB"]->Query($bquery);
                     if ($brow = $GLOBALS["ISC_CLASS_DB"]->Fetch($bresult)) {
                         // It's an existing brand
                         $brand_id = $brow['brandid'];
                     } else {
                         // It's a new brand, let's add it
                         $ba = array("brandname" => $prodbrand);
                         $GLOBALS['ISC_CLASS_DB']->InsertQuery("brands", $ba);
                         $brand_id = $GLOBALS["ISC_CLASS_DB"]->LastId();
                     }
                 } else {
                     // Delete the brand
                     $brand_id = 0;
                 }
             } else {
                 // The brand hasn't been changed
                 $brand_id = $prodbrandid;
             }
             if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() > 0) {
                 $featuredColumn = 'prodvendorfeatured';
             } else {
                 $featuredColumn = 'prodfeatured';
             }
             // Update the product details
             $pa = array("productid" => $product_id, "prodname" => $prodname, "prodprice" => $prodprice, "prodcalculatedprice" => $prodcalculatedprice, $featuredColumn => $prodfeatured, "prodvisible" => $prodvisible, "prodfreeshipping" => $prodfreeshipping, "prodbrandid" => $brand_id, "prodcatids" => $prodCatsCSV);
             $entity = new ISC_ENTITY_PRODUCT();
             $entity->bulkEdit($pa);
             // Save the words to the product_words table for search spelling suggestions
             $this->SaveProductWords($prodname, $product_id, "editing");
         }
         // Update product pricing
         $GLOBALS['ISC_CLASS_ADMIN_SETTINGS'] = GetClass('ISC_ADMIN_SETTINGS');
         $GLOBALS['ISC_CLASS_ADMIN_SETTINGS']->_UpdateProductPrices();
         // Do we want to keep editing or return to the products list?
         if (isset($_POST['keepediting'])) {
             $_POST['products'] = $product_ids;
             $this->BulkEditProductsStep1(GetLang("BulkEditUpdatedSuccessfully"), MSG_SUCCESS);
         } else {
             $this->ManageProducts(GetLang("BulkEditUpdatedSuccessfully"), MSG_SUCCESS);
         }
     } else {
         $this->ManageProducts();
     }
 }
 public function _UpdateProductPrices()
 {
     // Update the price of each and every product in the database
     $query = "select productid, prodprice, prodretailprice, prodsaleprice, prodistaxable from [|PREFIX|]products";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         // Workout the calculated price for this product as it will be displayed
         $calcprice = CalcRealPrice($row['prodprice'], $row['prodretailprice'], $row['prodsaleprice'], $row['prodistaxable']);
         // Run an update query
         $updatedProduct = array("prodcalculatedprice" => $calcprice);
         $GLOBALS['ISC_CLASS_DB']->UpdateQuery("products", $updatedProduct, "productid='" . $GLOBALS['ISC_CLASS_DB']->Quote($row['productid']) . "'");
     }
     // Log this action
     $GLOBALS['ISC_CLASS_LOG']->LogAdminAction();
 }
Example #4
0
/**
 * Calculate the price adjustment for a variation of a product.
 *
 * @var decimal The base price of the product.
 * @var string The type of adjustment to be performed (empty, add, subtract, fixed)
 * @var decimal The value to be adjusted by
 * @return decimal The adjusted value
 */
function CalcProductVariationPrice($basePrice, $type, $difference, $product=null)
{
	switch (strtolower($type)) {
		case "fixed":
			$newPrice = $difference;
			break;
		case "add":
			$newPrice = $basePrice + $difference;
			break;
		case "subtract":
			$adjustedCost = $basePrice - $difference;
			if($adjustedCost <= 0) {
				$adjustedCost = 0;
			}
			$newPrice = $adjustedCost;
			break;
		default:
			$newPrice =$basePrice;
	}

	if(!is_null($product)) {
		$newPrice = CalcProdCustomerGroupPrice($product, $newPrice);
	}

	// apply any tax if applicable.
	$newPrice = CalcRealPrice($newPrice, 0, 0);

	return $newPrice;
}
 private function PopupProductList()
 {
     /* if(isset($_REQUEST['seriesid']) && $_REQUEST['category'] == 0) {
            unset($_REQUEST['category']);
        }  */
     $seriesid = $_REQUEST['seriesid'];
     $brandid = $_REQUEST['brandid'];
     $_SESSION['radiotype'] = "series";
     $_SESSION['lastselseriesid'] = $seriesid;
     $_SESSION['lastselbrandid'] = $brandid;
     if (!isset($_REQUEST['seriesid'])) {
         $tags[] = $this->MakeXMLTag('status', 0);
         $tags[] = $this->MakeXMLTag('message', GetLang('ProductSelectEnterTerms'), true);
     } else {
         if (isset($_REQUEST['seriesid'])) {
             $_REQUEST['seriesid'] = array($_REQUEST['seriesid']);
         }
         $ResultCount = 0;
         $GLOBALS['ISC_CLASS_ADMIN_PRODUCT'] = GetClass('ISC_ADMIN_PRODUCT');
         $products = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]products where brandseriesid = '{$seriesid}' and prodbrandid = '{$brandid}'");
         $ResultCount = $GLOBALS["ISC_CLASS_DB"]->CountResult($products);
         if ($ResultCount == 0) {
             $tags[] = $this->MakeXMLTag('status', 0);
             if (isset($_REQUEST['searchQuery'])) {
                 $tags[] = $this->MakeXMLTag('message', GetLang('ProductSelectNoProducts'), true);
             } else {
                 $tags[] = $this->MakeXMLTag('message', GetLang('ProductSelectNoProductsBrands'), true);
             }
         } else {
             $results = '';
             $tags[] = $this->MakeXMLTag('status', 1);
             while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($products)) {
                 $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
                 $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice);
                 $isConfigurable = false;
                 if ($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0 || $product['prodeventdaterequired'] == 1) {
                     $isConfigurable = true;
                 }
                 $results .= '
                         <product>
                             <productId>' . $product['productid'] . '</productId>
                             <productName><![CDATA[' . $product['prodname'] . ']]></productName>
                             <productPrice>' . FormatPrice($actualPrice, false, false, true) . '</productPrice>
                             <productCode><![CDATA[' . $product['prodcode'] . ']]></productCode>
                             <productType>' . $product['prodtype'] . '</productType>
                             <productConfigurable>' . (int) $isConfigurable . '</productConfigurable>
                         </product>
                     ';
             }
             $tags[] = $this->MakeXMLTag('results', $results);
         }
     }
     $this->SendXMLHeader();
     $this->SendXMLResponse($tags);
     die;
 }
    /**
     * Show the select a product popup page on the create a coupon page
     *
     * @return void
     **/
    private function PopupProductSearch()
    {
        if (isset($_REQUEST['category']) && $_REQUEST['category'] == 0) {
            unset($_REQUEST['category']);
        }
        if (!isset($_REQUEST['searchQuery']) && !isset($_REQUEST['category'])) {
            $tags[] = $this->MakeXMLTag('status', 0);
            $tags[] = $this->MakeXMLTag('message', GetLang('ProductSelectEnterTerms'), true);
        } else {
            if (isset($_REQUEST['category'])) {
                $_REQUEST['category'] = array($_REQUEST['category']);
            }
            $ResultCount = 0;
            $GLOBALS['ISC_CLASS_ADMIN_PRODUCT'] = GetClass('ISC_ADMIN_PRODUCT');
            $products = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_GetProductList(0, 'prodname', 'asc', $ResultCount, 'p.productid,p.prodname,p.prodprice,p.prodsaleprice,p.prodretailprice,p.prodconfigfields,p.prodvariationid,p.prodtype,p.prodcode,p.prodistaxable,p.prodeventdaterequired', false);
            if ($ResultCount == 0) {
                $tags[] = $this->MakeXMLTag('status', 0);
                if (isset($_REQUEST['searchQuery'])) {
                    $tags[] = $this->MakeXMLTag('message', GetLang('ProductSelectNoProducts'), true);
                } else {
                    $tags[] = $this->MakeXMLTag('message', GetLang('ProductSelectNoProductsCategory'), true);
                }
            } else {
                $results = '';
                $tags[] = $this->MakeXMLTag('status', 1);
                while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($products)) {
                    $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
                    $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice);
                    $isConfigurable = false;
                    if ($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0 || $product['prodeventdaterequired'] == 1) {
                        $isConfigurable = true;
                    }
                    $results .= '
							<product>
								<productId>' . $product['productid'] . '</productId>
								<productName><![CDATA[' . $product['prodname'] . ']]></productName>
								<productPrice>' . FormatPrice($actualPrice, false, false, true) . '</productPrice>
								<productCode><![CDATA[' . $product['prodcode'] . ']]></productCode>
								<productType>' . $product['prodtype'] . '</productType>
								<productConfigurable>' . (int) $isConfigurable . '</productConfigurable>
							</product>
						';
                }
                $tags[] = $this->MakeXMLTag('results', $results);
            }
        }
        $this->SendXMLHeader();
        $this->SendXMLResponse($tags);
        die;
    }
 private function SearchProducts()
 {
     if (!isset($_REQUEST['searchQuery']) || $_REQUEST['searchQuery'] == '') {
         exit;
     }
     $groupId = 0;
     if (isset($_REQUEST['ordcustid']) && $_REQUEST['ordcustid'] != 0) {
         $customerClass = GetClass('ISC_CUSTOMER');
         $customer = $customerClass->GetCustomerInfo($_REQUEST['ordcustid']);
         if (isset($customer['custgroupid'])) {
             $groupId = $customer['custgroupid'];
         }
     } else {
         if (isset($_REQUEST['custgroupid']) && $_REQUEST['custgroupid'] != 0) {
             $groupId = (int) $_REQUEST['custgroupid'];
         }
     }
     $numProducts = 0;
     $products = GetClass('ISC_ADMIN_PRODUCT');
     $result = $products->_GetProductList(0, 'p.prodname', 'asc', $numProducts, 'DISTINCT p.*, ' . GetProdCustomerGroupPriceSQL($groupId), true);
     if ($numProducts == 0) {
         $searchQuery = isc_html_escape($_REQUEST['searchQuery']);
         $GLOBALS['OrderProductSearchNone'] = sprintf(GetLang('OrderProductSearchNone'), $searchQuery);
         echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchNoResults');
         exit;
     }
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['ProductId'] = $product['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($product['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($product['prodname']);
         $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
         $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice, $groupId);
         $GLOBALS['ProductPrice'] = FormatPrice($actualPrice);
         $GLOBALS['RawProductPrice'] = FormatPrice($actualPrice, false, false, true);
         $GLOBALS['ProductCode'] = isc_html_escape($product['prodcode']);
         $isConfigurable = false;
         if ($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) {
             $isConfigurable = true;
         }
         $GLOBALS['ProductConfigurable'] = (int) $isConfigurable;
         echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResult');
     }
 }
Example #8
0
 /**
  * Parse the product data
  *
  * Method will parse the product data to be inserted into the database
  *
  * @access private
  * @param array &$input The input data
  * @return NULL
  */
 private function parsedata(&$input)
 {
     // Workout the calculated price for this product as it will be displayed
     $input['prodcalculatedprice'] = CalcRealPrice($input['prodprice'], $input['prodretailprice'], $input['prodsaleprice'], $input['prodistaxable']);
     // If inventory tracking is on a product option basis, then product options are required
     if ($input['prodinvtrack'] == 2) {
         $input['prodoptionsrequired'] = 1;
     }
     // If we are importing and don't have any variations
     if (!array_key_exists('prodvariationid', $input)) {
         $input['prodvariationid'] = 0;
     }
     if (!array_key_exists('prodallowpurchases', $input)) {
         $input['prodallowpurchases'] = 1;
         $input['prodhideprice'] = 0;
         $input['prodcallforpricinglabel'] = '';
     }
     if (!array_key_exists('prodhideprice', $input)) {
         $input['prodhideprice'] = 0;
     }
     if (!array_key_exists('prodcallforpricinglabel', $input)) {
         $input['prodcallforpricinglabel'] = '';
     }
     //if (array_key_exists('prodcats', $input)) {
     //	$input['prodcatids'] = implode(',', $input['prodcats']);
     //} else {
     //$input['prodcatids'] = '';
     //}
     if (isset($input['prodcats']) and $input['prodcats'] != "") {
         $input['prodcatids'] = implode(',', $input['prodcats']);
     } else {
         $input['prodcatids'] = '';
     }
     if (!isset($input['prodvendorid'])) {
         $input['prodvendorid'] = 0;
     }
     if (isset($input['prodtags']) && $input['prodtags'] != '') {
         $input['prodhastags'] = 1;
     } else {
         $input['prodhastags'] = 0;
     }
     if (!isset($input['prodvendorfeatured'])) {
         $input['prodvendorfeatured'] = 0;
     }
     if (!isset($input['prodwrapoptions'])) {
         $input['prodwrapoptions'] = 0;
     }
     if (!isset($input['prodeventdatefieldname'])) {
         $input['prodeventdaterequired'] = 0;
         $input['prodeventdatefieldname'] = '';
         $input['prodeventdatelimited'] = 0;
         $input['prodeventdatelimitedtype'] = 0;
         $input['prodeventdatelimitedstartdate'] = 0;
         $input['prodeventdatelimitedenddate'] = 0;
     }
     $id = null;
     if (array_key_exists('productid', $input)) {
         $id = $input['productid'];
     }
     $input = array('prodname' => $input['prodname'], 'prodtype' => $input['prodtype'], 'prodcode' => $input['prodcode'], 'proddesc' => $input['proddesc'], 'prodmfg' => $input['prodmfg'], 'prodsearchkeywords' => $input['prodsearchkeywords'], 'prodalternates' => $input['prodalternates'], 'prodavailability' => $input['prodavailability'], 'prodprice' => $input['prodprice'], 'prodcostprice' => $input['prodcostprice'], 'prodretailprice' => $input['prodretailprice'], 'prodsaleprice' => $input['prodsaleprice'], 'prodcalculatedprice' => $input['prodcalculatedprice'], 'prodistaxable' => $input['prodistaxable'], 'prodsortorder' => $input['prodsortorder'], 'prodvisible' => $input['prodvisible'], 'prodfeatured' => $input['prodfeatured'], 'prodvendorfeatured' => (int) $input['prodvendorfeatured'], 'prodrelatedproducts' => $input['prodrelatedproducts'], 'prodinvtrack' => $input['prodinvtrack'], 'prodcurrentinv' => $input['prodcurrentinv'], 'prodlowinv' => $input['prodlowinv'], 'prodoptionsrequired' => $input['prodoptionsrequired'], 'prodwarranty' => $input['prodwarranty'], 'prodweight' => $input['prodweight'], 'prodwidth' => $input['prodwidth'], 'prodheight' => $input['prodheight'], 'proddepth' => $input['proddepth'], 'prodfixedshippingcost' => $input['prodfixedshippingcost'], 'prodfreeshipping' => $input['prodfreeshipping'], 'prodbrandid' => $input['prodbrandid'], 'prodpagetitle' => $input['prodpagetitle'], 'prodmetakeywords' => $input['prodmetakeywords'], 'prodmetadesc' => $input['prodmetadesc'], 'prodlayoutfile' => $input['prodlayoutfile'], 'prodvariationid' => $input['prodvariationid'], 'prodallowpurchases' => $input['prodallowpurchases'], 'prodhideprice' => $input['prodhideprice'], 'prodcallforpricinglabel' => $input['prodcallforpricinglabel'], 'prodcatids' => $input['prodcatids'], 'prodlastmodified' => time(), 'prodvendorid' => (int) $input['prodvendorid'], 'prodhastags' => $input['prodhastags'], 'prodwrapoptions' => $input['prodwrapoptions'], 'prodeventdaterequired' => $input['prodeventdaterequired'], 'prodeventdatefieldname' => $input['prodeventdatefieldname'], 'prodeventdatelimited' => $input['prodeventdatelimited'], 'prodeventdatelimitedtype' => $input['prodeventdatelimitedtype'], 'prodeventdatelimitedstartdate' => $input['prodeventdatelimitedstartdate'], 'prodeventdatelimitedenddate' => $input['prodeventdatelimitedenddate'], 'prodmyobasset' => $input['prodmyobasset'], 'prodmyobincome' => $input['prodmyobincome'], 'prodmyobexpense' => $input['prodmyobexpense'], 'prodpeachtreegl' => $input['prodpeachtreegl'], 'prodvendorprefix' => $input['prodvendorprefix'], 'proddescfeature' => $input['proddescfeature'], 'jobberprice' => $input['jobberprice'], 'mapprice' => $input['mapprice'], 'unilateralprice' => $input['unilateralprice'], 'alternativecategory' => $input['alternativecategory'], 'complementaryupcharge' => $input['complementaryupcharge'], 'ourcost' => $input['ourcost'], 'package_length' => $input['package_length'], 'package_width' => $input['package_width'], 'package_height' => $input['package_height'], 'package_weight' => $input['package_weight'], 'brandseriesid' => $input['brandseriesid'], 'future_retail_price' => $input['future_retail_price'], 'future_jobber_price' => $input['future_jobber_price'], 'prod_instruction' => $input['prod_instruction'], 'prod_article' => $input['prod_article'], 'skubarcode' => $input['skubarcode'], 'price_log' => $input['price_log'], 'SKU_last_update_time' => $input['SKU_last_update_time'], 'price_update_time' => $input['price_update_time'], 'install_time' => $input['install_time'], 'testdata' => $input['testdata'], 'comp_type' => $input['comp_type']);
     if (!is_null($id)) {
         $input['productid'] = $id;
     }
 }
Example #9
0
function CalculateProductPrice($product, $doLocaleFormat = true, $doCurrencyConvert = true, $strikeOutRetail = true)
{
    if (!GetConfig('ShowProductPrice') || $product['prodhideprice'] == 1) {
        return '';
    }
    $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
    $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice);
    // Calculate the actual price for this product in the current currency
    if ($doCurrencyConvert == true) {
        $actualPrice = ConvertPriceToCurrency($actualPrice);
    }
    $output = '';
    if ($doLocaleFormat) {
        // Does this product have a RRP?
        if ($actualPrice > 0 && $actualPrice < $product['prodretailprice'] && $strikeOutRetail == true) {
            $rrp = CalcProdCustomerGroupPrice($product, $product['prodretailprice']);
            $rrp = ConvertPriceToCurrency($product['prodretailprice']);
            $output .= '<strike>' . FormatPrice($rrp) . '</strike> ';
        }
    }
    if ($product['prodsaleprice'] > 0 && $product['prodsaleprice'] < $product['prodprice']) {
        $output .= '<span class="SalePrice">' . FormatPrice($actualPrice) . '</span>';
    } else {
        $output .= FormatPrice($actualPrice);
    }
    return $output;
}
 private function SearchProducts()
 {
     if (!isset($_REQUEST['searchQuery']) || $_REQUEST['searchQuery'] == '') {
         exit;
     }
     $groupId = 0;
     if (isset($_REQUEST['ordcustid']) && $_REQUEST['ordcustid'] != 0) {
         $customerClass = GetClass('ISC_CUSTOMER');
         $customer = $customerClass->GetCustomerInfo($_REQUEST['ordcustid']);
         if (isset($customer['custgroupid'])) {
             $groupId = $customer['custgroupid'];
         }
     } else {
         if (isset($_REQUEST['custgroupid']) && $_REQUEST['custgroupid'] != 0) {
             $groupId = (int) $_REQUEST['custgroupid'];
         }
     }
     $numProducts = 0;
     $products = GetClass('ISC_ADMIN_PRODUCT');
     /***********************************************************************
     				Altered By Mayank Jaitly 12 July 2010
     				Original Code is in the else
     			/***********************************************************************/
     if (isset($_REQUEST['w']) && $_REQUEST['w'] == 'orderSearchProducts') {
         $result = $products->_GetProductList(0, 'ct.catuniversal,p.prodname', 'asc', $numProducts, 'DISTINCT p.*, ' . GetProdCustomerGroupPriceSQL($groupId), true);
     } else {
         $result = $products->_GetProductList(0, 'p.prodname', 'asc', $numProducts, 'DISTINCT p.*, ' . GetProdCustomerGroupPriceSQL($groupId), true);
     }
     if ($numProducts == 0) {
         $searchQuery = isc_html_escape($_REQUEST['searchQuery']);
         $GLOBALS['OrderProductSearchNone'] = sprintf(GetLang('OrderProductSearchNone'), $searchQuery);
         echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchNoResults');
         exit;
     }
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['ProductId'] = $product['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($product['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($product['prodname']);
         $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
         $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice, $groupId);
         $GLOBALS['ProductPrice'] = FormatPrice($actualPrice);
         $GLOBALS['RawProductPrice'] = FormatPrice($actualPrice, false, false, true);
         $GLOBALS['ProductCode'] = isc_html_escape($product['prodcode']);
         $isConfigurable = false;
         if ($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) {
             $isConfigurable = true;
         }
         $GLOBALS['ProductConfigurable'] = (int) $isConfigurable;
         /************************************************************************
         				Code Altered by Mayank Jaitly on 01 July 2010
         				Original code is with comment area
         			echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResult');
         			/***************************************************************************/
         /// Start of alteration
         if (isset($_REQUEST['ajaxsearchtype']) && $_REQUEST['ajaxsearchtype'] == '2') {
             $GLOBALS['SKU'] = isc_html_escape($product['prodvendorprefix']);
             echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResultSKU');
         } else {
             echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResult');
         }
         //// End of alteration
     }
 }
Example #11
0
 /**
  * Insert an imported product in to the database. This function also performs any necessary validation & error checking.
  * It also handles inserting product images, downloads, custom fields, options and other product information.
  *
  * @param int The ID of the product from the existing system.
  * @param array Array of product information to insert.
  * @param string The import error message (returned by reference)
  * @return boolean True if successful, false on failure.
  */
 public function InsertProduct($productId, $productData, &$err)
 {
     if (!isset($productData['prodname']) || $productData['prodname'] == '') {
         $err = sprintf(GetLang('ImportProductErrorInvalid'), $productId);
         $this->_LogImportError('invalid', $err);
         return false;
     }
     if (!isset($productData['categories']) || count($productData['categories']) == 0) {
         $err = sprintf(GetLang('ImportProductErrorInvalidCategory'), $productData['prodname']);
         $this->_LogImportError('invalid', $err);
         return false;
     }
     if (!isset($productData['prodprice'])) {
         $err = sprintf(GetLang('ImportProductErrorInvalidPrice'), $productData['prodname']);
         $this->_LogImportError('invalid', $err);
         return false;
     }
     if ($this->IsDuplicateProduct($productData['prodname'])) {
         $err = sprintf(GetLang('ImportProductErrorDuplicate'), $productData['prodname']);
         $this->_LogImportError('duplicates', $err);
         return false;
     }
     if (isset($productData['downloads']) && count($productData['downloads']) > 0) {
         $productData['prodtype'] = 2;
     } else {
         $productData['prodtype'] = 1;
     }
     // We have a brand name and we've also chosen to import brand names
     if (isset($productData['prodbrandid'])) {
         $brandId = $this->GetImportBrandId($productData['prodbrandid']);
     } else {
         $brandId = 0;
     }
     if (!isset($productData['prodvisible']) || $productData['prodvisible'] != 0) {
         $productData['prodvisible'] = 1;
     }
     if (!isset($productData['prodfeatured']) || $productData['prodfeatured'] != 1) {
         $productData['prodfeatured'] = 0;
     }
     if (!isset($productData['prodfreeshipping']) || $productData['prodfreeshipping'] != 1) {
         $productData['prodfreeshipping'] = 0;
     }
     if (!isset($productData['prodinvtrack']) || $productData['prodinvtrack'] != 1 && $productData['prodinvtrack'] != 2) {
         $productData['prodinvtrack'] = 0;
     }
     if (!isset($productData['prodsearchkeywords'])) {
         $productData['prodsearchkeywords'] = '';
     }
     if (!isset($productData['prodavailability'])) {
         $productData['prodavailability'] = '';
     }
     if (!isset($productData['prodsaleprice'])) {
         $productData['prodsaleprice'] = 0;
     }
     if (!isset($productData['prodcostprice'])) {
         $productData['prodcostprice'] = 0;
     }
     if (!isset($productData['prodretailprice'])) {
         $productData['prodretailprice'] = 0;
     }
     if (!isset($productData['prodsortorder'])) {
         $productData['prodsortorder'] = 0;
     }
     if (!isset($productData['prodrelatedproducts'])) {
         $productData['prodrelatedproducts'] = -1;
     } else {
         if (is_array($productData['prodrelatedproducts'])) {
             $productData['prodrelatedproducts'] = implode(",", $productData['prodrelatedproducts']);
         }
     }
     if (!isset($productData['prodwarranty'])) {
         $productData['prodwarranty'] = '';
     }
     if (!isset($productData['prodwidth'])) {
         $productData['prodwidth'] = 0;
     }
     if (!isset($productData['proddepth'])) {
         $productData['proddepth'] = 0;
     }
     if (!isset($productData['prodheight'])) {
         $productData['prodheight'] = 0;
     }
     if (!isset($productData['prodfixedshippingcost'])) {
         $productData['prodfixedshippingcost'] = 0;
     }
     if (!isset($productData['prodoptionsrequired'])) {
         $productData['prodoptionsrequired'] = 0;
     }
     if (!isset($productData['prodnumviews'])) {
         $productData['prodnumviews'] = 0;
     }
     if (!isset($productData['prodmetakeywords'])) {
         $productData['prodmetakeywords'] = '';
     }
     if (!isset($productData['prodmetadesc'])) {
         $productData['prodmetadesc'] = '';
     }
     if (!isset($productData['prodlayoutfile'])) {
         $productData['prodlayoutfile'] = 0;
     }
     $calculatedPrice = CalcRealPrice($productData['prodprice'], @$productData['prodretailprice'], @$productData['prodretailprice'], @$productData['prodistaxable']);
     $prodCats = array();
     // Insert any category associations
     foreach ($productData['categories'] as $catId) {
         $categoryId = $this->GetImportCategoryId($catId);
         $prodCats[] = $categoryId;
     }
     $prodCatsCSV = implode(',', $prodCats);
     $product = array("importproductid" => $productId, "prodname" => $productData['prodname'], "prodtype" => (int) $productData['prodtype'], "prodcode" => $productData['prodcode'], "proddesc" => $productData['proddesc'], "prodsearchkeywords" => $productData['prodsearchkeywords'], "prodavailability" => $productData['prodavailability'], "prodprice" => (double) $productData['prodprice'], "prodcostprice" => (double) $productData['prodcostprice'], "prodretailprice" => (double) $productData['prodretailprice'], "prodsaleprice" => (double) $productData['prodsaleprice'], "prodcalculatedprice" => (double) $calculatedPrice, "prodsortorder" => (int) $productData['prodsortorder'], "prodvisible" => $productData['prodvisible'], "prodfeatured" => $productData['prodfeatured'], "prodrelatedproducts" => $productData['prodrelatedproducts'], "prodcurrentinv" => (int) $productData['prodcurrentinv'], "prodlowinv" => (int) $productData['prodlowinv'], "prodoptionsrequired" => $productData['prodoptionsrequired'], "prodwarranty" => $productData['prodwarranty'], "prodweight" => (double) $productData['prodweight'], "prodwidth" => (double) $productData['prodwidth'], "prodheight" => (double) $productData['prodheight'], "proddepth" => (double) $productData['proddepth'], "prodfixedshippingcost" => (double) $productData['prodfixedshippingcost'], "prodfreeshipping" => $productData['prodfreeshipping'], "prodinvtrack" => $productData['prodinvtrack'], "prodratingtotal" => 0, "prodnumratings" => 0, "prodnumsold" => (int) $productData['prodnumsold'], "proddateadded" => (int) $productData['proddateadded'], "prodbrandid" => $brandId, "prodnumviews" => (int) $productData['prodnumviews'], "prodmetakeywords" => $productData['prodmetakeywords'], "prodmetadesc" => $productData['prodmetadesc'], "prodcatids" => $prodCatsCSV, "prodmyobasset" => '', "prodmyobincome" => '', "prodmyobexpense" => '', "prodpeachtreegl" => '');
     $productId = $this->ConvertedInsertQuery("products", $product);
     if (!$productId) {
         $err = "Failed to insert product (DEBUG)";
         $this->_LogImportError('invalid', $err);
         return false;
     }
     // Insert any category associations
     foreach ($prodCats as $categoryId) {
         $association = array("productid" => $productId, "categoryid" => $categoryId);
         $this->ConvertedInsertQuery("categoryassociations", $association);
     }
     // Are there any product images that need to be inserted?
     $has_thumb = false;
     $has_tiny = false;
     $thumb_file = '';
     $tiny_file = '';
     $firstImage = '';
     if (is_array($productData['images'])) {
         $GLOBALS['ISC_CLASS_ADMIN_PRODUCT'] = GetClass('ISC_ADMIN_PRODUCT');
         foreach ($productData['images'] as $k => $image) {
             // Only copy across product images that exist
             if (isset($image['imagefile']) && !file_exists($image['imagefile'])) {
                 continue;
             }
             // Copy the file across to the store
             $randomDir = strtolower(chr(rand(65, 90)));
             if (!is_dir(ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/" . $randomDir)) {
                 if (!@mkdir(ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/" . $randomDir, 0777)) {
                     $randomDir = '';
                 }
             }
             if (isset($image['imagedata']) && $image['imagedata'] !== '') {
                 $fileName = $randomDir . "/" . GenRandFileName($image['imagefilename']);
             } else {
                 $fileName = $randomDir . "/" . GenRandFileName(basename($image['imagefile']));
             }
             $dest = ISC_BASE_PATH . "/" . GetConfig('ImageDirectory');
             $dest .= "/" . $fileName;
             if (isset($image['imagedata']) && $image['imagedata'] !== '') {
                 file_put_contents($dest, $image['imagedata']);
             } else {
                 copy($image['imagefile'], $dest);
             }
             // Is this image supposed to be a thumbnail?
             if (isset($image['imageisthumb']) && $image['imageisthumb'] == 1) {
                 if (!$has_thumb) {
                     $has_thumb = true;
                     $thumb_file = $fileName;
                 }
                 continue;
             }
             // Is this image supposed to be a tiny version?
             if (isset($image['imageisthumb']) && $image['imageisthumb'] == 2) {
                 if (!$has_tiny) {
                     $has_tiny = true;
                     $tiny_file = $fileName;
                 }
                 continue;
             }
             if ($firstImage == '') {
                 $firstImage = $fileName;
             }
             // A normal product image
             $newImage = array("imageprodid" => $productId, "imagefile" => $fileName, "imageisthumb" => $image['imageisthumb'], "imagesort" => $k + 1);
             $this->ConvertedInsertQuery("product_images", $newImage);
         }
         // Now the main images are done, we can build the thumbnails
         if ($firstImage && !$thumb_file) {
             $thumb_file = $firstImage;
             $thumb = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_AutoGenerateThumb($firstImage, "thumb");
         } else {
             // Override the existing thumbnail image with the smaller version
             $thumb = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_AutoGenerateThumb($thumb_file, "thumb", true);
         }
         if ($thumb) {
             $newImage = array("imageprodid" => $productId, "imagefile" => $thumb, "imageisthumb" => 1, "imagesort" => 0);
             $this->ConvertedInsertQuery("product_images", $newImage);
             // If we don't have a tiny version, default to the thumb size and we'll generate it below
             if (!$tiny_file) {
                 $tiny_file = $thumb;
             }
         }
         if ($tiny_file != '') {
             $thumb = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_AutoGenerateThumb($tiny_file, "tiny");
             if ($thumb) {
                 $newImage = array("imageprodid" => $productId, "imagefile" => $thumb, "imageisthumb" => 2, "imagesort" => 0);
                 $this->ConvertedInsertQuery("product_images", $newImage);
             }
         }
     }
     // Are there any custom fields that need to be inserted for this product?
     if (isset($productData['customfields']) && is_array($productData['customfields'])) {
         foreach ($productData['customfields'] as $name => $value) {
             if ($name === '') {
                 continue;
             }
             $newField = array("fieldprodid" => $productId, "fieldname" => $name, "fieldvalue" => $value);
             $this->ConvertedInsertQuery("product_customfields", $newField);
         }
     }
     $variationId = 0;
     // Are there any variations for this product?
     if (isset($productData['variations']) && is_array($productData['variations'])) {
         // Create a variation group for this set of variations
         $newVariation = array("vname" => $productData['prodname'] . " Options", "vnumoptions" => 0);
         $variationId = $this->ConvertedInsertQuery("product_variations", $newVariation);
         // Insert the different combinations we have
         $vOptions = array();
         foreach ($productData['variations'] as $variation) {
             if (!isset($variation['vcsku'])) {
                 $variation['vcsku'] = '';
             }
             if (!isset($variation['vcpricediff'])) {
                 $variation['vcpricediff'] = '';
             }
             if (!isset($variation['vcprice'])) {
                 $variation['vcpricediff'] = 0;
             }
             if (!isset($variation['vcweightdiff'])) {
                 $variation['vcweightdiff'] = '';
             }
             if (!isset($variation['vcweight'])) {
                 $variation['vcweight'] = 0;
             }
             if (!isset($variation['vcstock'])) {
                 $variation['vcstock'] = 0;
             }
             if (!isset($variation['vclowstock'])) {
                 $variation['vclowstock'] = 0;
             }
             $imageFile = '';
             $thumbFile = '';
             // This variation has an image, we need to copy it across
             if (isset($variation['vcimage']) && $variation['vcimage'] != '') {
                 if (file_exists($variation['vcimage'])) {
                     // Copy across to the store
                     $randomDir = strtolower(chr(rand(65, 90)));
                     if (!is_dir(ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/" . $randomDir)) {
                         if (!@mkdir(ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/" . $randomDir, 0777)) {
                             $randomDir = '';
                         }
                     }
                     $fileName = $randomDir . "/" . GenRandFileName(basename($variation['vcimage']));
                     $dest = ISC_BASE_PATH . "/" . GetConfig('ImageDirectory');
                     $dest .= "/" . $fileName;
                     if (!copy($variation['vcimage'], $dest)) {
                         $imageFile = '';
                         $mainDest = $dest;
                     } else {
                         $imageFile = $fileName;
                         if (!isset($variation['vcthumb']) || $variation['vcthumb'] == '') {
                             $variation['vcthumb'] = $dest;
                         }
                     }
                 }
             }
             // This variation has a thumb
             if (isset($variation['vcthumb']) && $variation['vcthumb'] != '') {
                 if (file_exists($variation['vcthumb'])) {
                     // Copy across to the store
                     $randomDir = strtolower(chr(rand(65, 90)));
                     if (!is_dir(ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/" . $randomDir)) {
                         if (!@mkdir(ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/" . $randomDir, 0777)) {
                             $randomDir = '';
                         }
                     }
                     $fileName = $randomDir . "/" . GenRandFileName(basename($variation['vcthumb']));
                     $dest = ISC_BASE_PATH . "/" . GetConfig('ImageDirectory');
                     $dest .= "/" . $fileName;
                     // Copied across the image
                     if (copy($variation['vcthumb'], $dest)) {
                         // Now we need to resize it
                         $thumbFile = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_AutoGenerateThumb($dest, "thumb", true);
                     }
                 }
             }
             // Build the list of option IDs
             $optionIds = array();
             foreach ($variation['options'] as $optName => $optValue) {
                 if (!isset($vOptions[$optName][$optValue])) {
                     // Creating a new option
                     $newOption = array("vovariationid" => $variationId, "voname" => $optName, "vovalue" => $optValue);
                     $vOptions[$optName][$optValue] = $this->ConvertedInsertQuery("product_variation_options", $newOption);
                 }
                 $optionIds[] = $vOptions[$optName][$optValue];
             }
             $optionIds = implode(",", $optionIds);
             // Now insert the actual combination
             $newCombination = array("vcproductid" => $productId, "vcvariationid" => $variationId, "vcenabled" => 1, "vcoptionids" => $optionIds, "vcsku" => $variation['vcsku'], "vcpricediff" => $variation['vcpricediff'], "vcprice" => $variation['vcprice'], "vcweightdiff" => $variation['vcweightdiff'], "vcweight" => $variation['vcweight'], "vcimage" => $imageFile, "vcthumb" => $thumbFile, "vcstock" => $variation['vcstock'], "vclowstock" => $variation['vclowstock']);
             // Insert the combination
             $this->ConvertedInsertQuery("product_variation_combinations", $newCombination);
         }
         $updatedProduct = array("prodvariationid" => $variationId);
         $GLOBALS['ISC_CLASS_DB']->UpdateQuery("products", $updatedProduct, "productid='" . $productId . "'");
         // Set the number of options for this variation set
         $updatedVariation = array("vnumoptions" => count($vOptions));
         $GLOBALS['ISC_CLASS_DB']->UpdateQuery("product_variations", $updatedVariation, "variationid='" . $variationId . "'");
     }
     // Are there any downloads for this product?
     if (isset($productData['downloads']) && is_array($productData['downloads'])) {
         foreach ($productData['downloads'] as $download) {
             if (!isset($download['downname']) || empty($download['downname'])) {
                 $download['downname'] = basename($download['downfile']);
             }
             $download['downfile'] = realpath($download['downfile']);
             // Only copy across product images that exist
             if (!file_exists($download['downfile']) || !is_file($download['downfile'])) {
                 continue;
             }
             // Copy the file across to the store
             $fileName = GenRandFileName(basename($download['downfile']));
             $dest = realpath(dirname(__FILE__) . "/../../../" . GetConfig('DownloadDirectory'));
             $dest .= "/" . $fileName;
             copy($download['downfile'], $dest);
             if (!isset($download['downdateadded'])) {
                 $download['downdateadded'] = time();
             }
             if (!isset($download['downmaxdownloads'])) {
                 $download['downmaxdownloads'] = 0;
             }
             if (!isset($download['downexpiresafter'])) {
                 $download['downexpiresafter'] = 0;
             }
             if (!isset($download['downdescription'])) {
                 $download['downdescription'] = basename($download['downfile']);
             }
             if (!isset($download['downfilezie'])) {
                 $download['downfilesize'] = filesize($download['downfile']);
             }
             $newDownload = array("prodhash" => '', "productid" => $productId, "downfile" => $fileName, "downdateadded" => (int) $download['downdateadded'], "downmaxdownloads" => (int) $download['downmaxdownloads'], "downexpiresafter" => (int) $download['downexpiresafter'], "downfilesize" => (int) $download['downfilesize'], "downname" => basename($download['downname']), "downdescription" => $download['downdescription']);
             $this->ConvertedInsertQuery("product_downloads", $newDownload);
         }
     }
     // Insert the search data for this product
     $searchData = array("productid" => $productId, "prodname" => $productData['prodname'], "prodcode" => $productData['prodcode'], "proddesc" => $productData['proddesc'], "prodsearchkeywords" => $productData['prodsearchkeywords']);
     $this->ConvertedInsertQuery("product_search", $searchData);
     // Build the product words list
     $GLOBALS['ISC_CLASS_ADMIN_PRODUCT'] = GetClass('ISC_ADMIN_PRODUCT');
     $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->SaveProductWords($GLOBALS['ISC_CLASS_DB']->Quote($productData['prodname']), $productId, "adding");
     return $productId;
 }
Example #12
0
	protected function editPrehook($productId, &$savedata, $rawInput)
	{
		/**
		 * Workout the calculated price for this product as it will be displayed
		 */
		if (isset($rawInput["prodprice"]) && isset($rawInput["prodretailprice"]) && isset($rawInput["prodsaleprice"])) {
			$savedata["prodcalculatedprice"] = CalcRealPrice($rawInput["prodprice"], $rawInput["prodsaleprice"]);
		}

		/**
		 * If inventory tracking is on a product option basis, then product options are required
		 */
		if (array_key_exists("prodinvtrack", $savedata) && $savedata["prodinvtrack"] == 2) {
			$savedata["prodoptionsrequired"] = 1;
		}

		if (isset($rawInput["prodcats"])) {
			$savedata["prodcatids"] = implode(",", $rawInput["prodcats"]);
		}

		$savedata["prodlastmodified"] = time();

		return true;
	}