/** * Generate the bulk discounts window if this product has any. */ public function SetBulkDiscounts() { // Does this product have any bulk discount? if (!$this->productClass->CanUseBulkDiscounts()) { $GLOBALS['HideBulkDiscountLink'] = 'none'; return; } $GLOBALS['HideBulkDiscountLink'] = ''; $GLOBALS['BulkDiscountThickBoxTitle'] = sprintf(GetLang('BulkDiscountThickBoxTitle'), isc_html_escape($this->productClass->GetProductName())); $rates = ''; $prevMax = 0; $query = " SELECT * FROM [|PREFIX|]product_discounts WHERE discountprodid = " . (int)$this->productClass->GetProductId() . " ORDER BY IF(discountquantitymax > 0, discountquantitymax, discountquantitymin) ASC "; $result = $this->db->Query($query); while ($row = $this->db->Fetch($result)) { $range = ''; if ($row['discountquantitymin'] == 0) { $range = isc_html_escape(intval($prevMax+1) . ' - ' . (int)$row['discountquantitymax']); } else if ($row['discountquantitymax'] == 0) { $range = isc_html_escape(sprintf(GetLang('BulkDiscountThickBoxDiscountOrAbove'), (int)$row['discountquantitymin'])); } else { $range = isc_html_escape((int)$row['discountquantitymin'] . ' - ' . (int)$row['discountquantitymax']); } $discount = ''; switch (isc_strtolower(isc_html_escape($row['discounttype']))) { case 'price': $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountPrice'), $range, CurrencyConvertFormatPrice(isc_html_escape($row['discountamount']))); break; case 'percent': $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountPercent'), $range, (int)$row['discountamount'] . '%'); break; case 'fixed'; $price = CalculateCustGroupDiscount($this->productClass->GetProductId(),$row['discountamount']); $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountFixed'), $range, CurrencyConvertFormatPrice(isc_html_escape($price))); break; } $rates .= '<li>' . isc_html_escape($discount) . '</li>'; if ($row['discountquantitymax'] !== 0) { $prevMax = $row['discountquantitymax']; } } $GLOBALS['BulkDiscountThickBoxRates'] = $rates; $GLOBALS['ProductBulkDiscountThickBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductBulkDiscountThickBox"); }
/** * Get the bulk discount rates HTML * * Method will return the bulk discount rates HTML to be used in the bulk discount thickbok * * @access public * @return string The bulk discount HTML list */ public function GetProductBulkDiscounts() { $rates = ''; $prevMax = 0; $query = "SELECT *\n\t\t\t\t\t\tFROM [|PREFIX|]product_discounts\n\t\t\t\t\t\tWHERE discountprodid = " . (int) $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "\n\t\t\t\t\t\tORDER BY IF(discountquantitymax > 0, discountquantitymax, discountquantitymin) ASC"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $range = ''; if ($row['discountquantitymin'] == 0) { $range = isc_html_escape(intval($prevMax + 1) . ' - ' . (int) $row['discountquantitymax']); } else { if ($row['discountquantitymax'] == 0) { $range = isc_html_escape(sprintf(GetLang('BulkDiscountThickBoxDiscountOrAbove'), (int) $row['discountquantitymin'])); } else { $range = isc_html_escape((int) $row['discountquantitymin'] . ' - ' . (int) $row['discountquantitymax']); } } $discount = ''; switch (isc_strtolower(isc_html_escape($row['discounttype']))) { case 'price': $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountPrice'), $range, CurrencyConvertFormatPrice(isc_html_escape($row['discountamount']))); break; case 'percent': $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountPercent'), $range, (int) $row['discountamount'] . '%'); break; case 'fixed': $price = CalculateCustGroupDiscount($GLOBALS['ISC_CLASS_PRODUCT']->GetProductId(), $row['discountamount']); $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountFixed'), $range, CurrencyConvertFormatPrice(isc_html_escape($price))); break; } $rates .= '<li>' . isc_html_escape($discount) . '</li>'; if ($row['discountquantitymax'] !== 0) { $prevMax = $row['discountquantitymax']; } } return $rates; }