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; } } }
/** * 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; }
public function GetFinalPrice() { return CalcProdCustomerGroupPrice($this->_product, $this->_prodcalculatedprice); }
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'); } }
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 } }