24 Sep 2026, 12:44 PM
[edited]
Totally Zenned
- Join Date:
- Jan 2013
- Location:
- New Port Richey, Florida
- Posts:
- 970
- Plugin Contributions:
- 0
quantity qiscounts and decimals
``i sell some products by the sq. ft. so a box might be 24.028 if they buy it by the pallet (quantity Discounts) which is 1321.54 per pallet but when adding a decimal to quantity discounts the quantity discounts dont show. this is what i have in tpl product info display
<!--bof Quantity Discounts table -->
<?php
if ($products_discount_type != 0) {
$qty_discounts = $db->Execute("SELECT * FROM " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . "
WHERE products_id = " . (int)$_GET['products_id'] . "
ORDER BY discount_qty ASC");
$discount_lines = array();
$actual_price = zen_get_products_actual_price((int)$_GET['products_id']);
while (!$qty_discounts->EOF) {
$bulkqty = $qty_discounts->fields['discount_qty'];
$discount_price = zen_get_products_discount_price_qty((int)$_GET['products_id'], $bulkqty);
if ($discount_price < $actual_price) {
$unit = ($calculator == 1 || $calculator == 2) ? 'SqFt' : 'ea';
$percent = round($qty_discounts->fields['discount_price']);
// Calculate Cash Savings: (Normal Price - Bulk Price) * Quantity
$savings_per_unit = $actual_price - $discount_price;
$total_saved_cash = '$' . number_format($savings_per_unit * $bulkqty, 2);
$price_fmt = '$' . number_format($discount_price, 2);
// Format: "500+ SqFt: $2.49 (Save 10% — $125.00 total)"
$discount_lines[] = "<strong>{$bulkqty}+ {$unit}:</strong> {$price_fmt} <span style='color:#28a745;'>(Save {$percent}% — {$total_saved_cash} total)</span>";
}
$qty_discounts->MoveNext();
}
if (count($discount_lines) > 0) {
echo '<div class="qty-discounts" style="font-size: 0.95em; margin: 15px 0; border-left: 4px solid #28a745; padding-left: 12px; line-height: 1.5;">';
if (count($discount_lines) === 1) {
echo 'Bulk Discount: ' . $discount_lines[0];
} else {
echo '<div style="margin-bottom:5px; text-transform:uppercase; font-weight:bold; font-size:0.8em; color:#666;">Volume Savings:</div>';
echo implode('<br>', $discount_lines);
}
echo '</div>';
}
}
?>
<!--eof Quantity Discounts table -->
thanks for looking