Hello
I have spent the afternoon trying to get the product listing page to show the price range available for products with quantity discounts on them. After reading through a couple of related threads, I have successfully managed to do this with the following piece of code:
PHP Code:
<!--bof Product Price block -->
<h2 id="productPrices" class="productGeneral">
<?php
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
// qty discount
$qty_discount = zen_get_products_discount_price_qty((int)$_GET['products_id'],999999);
$actual_price = zen_get_products_actual_price((int)$_GET['products_id']);
$base_price = zen_get_products_base_price((int)$_GET['products_id']);
if ($qty_discount < $actual_price) {
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . '<meta itemprop="priceCurrency" content="' . $_SESSION['currency'] . '" />' . '<span itemprop="price"><span class="normalprice">' . $currencies->display_price($base_price, zen_get_tax_rate($products_tax_class_id)) . '</span> ' . $currencies->display_price($qty_discount, zen_get_tax_rate($products_tax_class_id)) . ' - ' . $currencies->display_price($actual_price, zen_get_tax_rate($products_tax_class_id)) . '</span>';
} else {
// base price
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . '<meta itemprop="priceCurrency" content="' . $_SESSION['currency'] . '" />' . '<span itemprop="price">' . zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
}
?></h2>
<!--eof Product Price block -->
My only issue with this is that this code leaves the base price of the product on the listing. As an example, we have a product with a price of $10 that is on special for $9 and has a quantity discount of $7.50 if you purchase 3 or more -- the code above produces the following:
$10.00 $7.50 - $9.00
This is fine for products with specials/sales on them, however I can't get it off products that don't have specials/sales on them.
This is the code I've been trying to make work to remove the strike through on products without specials/sales:
PHP Code:
<!--bof Product Price block -->
<h2 id="productPrices" class="productGeneral">
<?php
if ($show_onetime_charges_description == 'true') {
$one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
} else {
$one_time = '';
}
// qty discount
$qty_discount = zen_get_products_discount_price_qty((int)$_GET['products_id'],999999);
$actual_price = zen_get_products_actual_price((int)$_GET['products_id']);
$base_price = zen_get_products_base_price((int)$_GET['products_id']);
$special_price = zen_get_products_special_price($products_id, true);
$sale_price = zen_get_products_special_price($products_id, false);
if ($qty_discount < $actual_price and ($special_price != 1 or $sale_price != 1)) {
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . '<meta itemprop="priceCurrency" content="' . $_SESSION['currency'] . '" />' . '<span itemprop="price"><span class="normalprice">' . $currencies->display_price($base_price, zen_get_tax_rate($products_tax_class_id)) . '</span> ' . $currencies->display_price($qty_discount, zen_get_tax_rate($products_tax_class_id)) . ' - ' . $currencies->display_price($actual_price, zen_get_tax_rate($products_tax_class_id)) . '</span>';
} elseif ($qty_discount < $actual_price and ($special_price != 0 or $sale_price != 0)) {
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . '<meta itemprop="priceCurrency" content="' . $_SESSION['currency'] . '" />' . '<span itemprop="price">' . $currencies->display_price($qty_discount, zen_get_tax_rate($products_tax_class_id)) . ' - ' . $currencies->display_price($actual_price, zen_get_tax_rate($products_tax_class_id)) . '</span>';
} else {
// base price
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . '<meta itemprop="priceCurrency" content="' . $_SESSION['currency'] . '" />' . '<span itemprop="price">' . zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
}
?></h2>
<!--eof Product Price block -->
But this is doing nothing for me and just keeps the base price with a strike through and then follows with the quantity discounts:
$10.00 $7.50 - $10.00
Any ideas?