Here is the code you supplied:
PHP Code:
// Price Functions Improvement
function pt_get_discount_amount($products_id) {
global $db, $currencies;
$show_sale_discount = '';
$display_normal_price = zen_get_products_base_price($products_id);
$display_special_price = zen_get_products_special_price($products_id, true);
$display_sale_price = zen_get_products_special_price($products_id, false);
if (SHOW_SALE_DISCOUNT_STATUS == '1' and ($display_special_price != 0 or $display_sale_price != 0)) {
if ($display_sale_price) { IF THIS IS A SALE AND NOT A SPECIAL
if (SHOW_SALE_DISCOUNT == 1) { IF SHOW AS A PERCENT IS SET
if ($display_normal_price != 0) {
$show_discount_amount = number_format(100 - (($display_sale_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
} else {
$show_discount_amount = '';
}
$show_sale_discount = $show_discount_amount . PRODUCT_PRICE_DISCOUNT_PERCENTAGE;
} else { IF SHOW AS AN AMOUNT IS SET
$show_sale_discount = $currencies->display_price(($display_normal_price - $display_sale_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT;
}
} else { (IF THIS IS A SPECIAL AND NOT A SALE)
if (SHOW_SALE_DISCOUNT == 1) { IF SHOW AS A % IS SET
$show_sale_discount = number_format(100 - (($display_special_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS) . PRODUCT_PRICE_DISCOUNT_PERCENTAGE;
} else { IF SHOW AS AN AMOUNT IS SET
$show_sale_discount = $currencies->display_price(($display_normal_price - $display_special_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT;
}
}
}
return $show_sale_discount;
Hello again
I put the logic of your code in blue. With your example, the parts after "if SHOW AS AN AMOUNT IS SET" are the parts that compute the sales discount and returns it as a string with other crap (like the % sign or decimals). Except, it looks the same as the code in the normal functions_prices.php. (did you compare it against the code in functions_prices.php with an unmodified zencart? I'm very tired so maybe I'm not seeing it, BUT the only difference I see is that they have a class assigned which prob formats the string. So I'm stumped.
I would look at the code where this is returned and see if any more modifications are done to it before it is displayed.
Question: Did you test it with % to see if it gives the correct %? I would do that next.
Also, are you running version 1.54 of Zencart?
I'm sure someone will be back to help before I wake up and I know I will be anxious to see what the heck is wrong. But if not, I'll help you look some more. Sorry I'm no expert.
Linda