the below code is doing my job from another post on this forum, except it gives a fixed amount of discounts of 5, any one know how to change this so it only shows the amount of discounts used, some might have 1 some might have more
thanks
Bryan
PHP Code:
$products_discount_type = zen_products_lookup($relatedResult->fields['products_id'], $what_field = 'products_discount_type');
$columns ++;
$products_id_current = (int)$relatedResult->fields['products_id'];
$quantityDiscounts = array();
$products_discount_type_from = zen_products_lookup($relatedResult->fields['products_id'], $what_field = 'products_discount_type_from');
require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCTS_QUANTITY_DISCOUNTS));
// The following lines are my long & heavy but seemingly functional code, I've adapted it from tpl_modules_products_quantity_discounts as I couldn't get the foreach statement to work here
$discount_level_1 = $quantityDiscounts[0];
$discount_level_2 = $quantityDiscounts[1];
$discount_level_3 = $quantityDiscounts[2];// This goes up to 5 discount levels, add more if you have more than 5 levels
$discount_level_4 = $quantityDiscounts[3];// or remove some if you have less than 5 levels
$discount_level_5 = $quantityDiscounts[4];
if ($products_discount_type != 0) {
// I've adapted the following table style from my custom tpl_modules_product_quantity_discounts, I've made it more vertical to make it fit better, if you want the original horizontal layout you can find the code in tpl_modules_product_quantity_discounts
//NB the TEXT_HEADER below is for ACTUAL PRICE DISCOUNTS it could be replaced with the alternatives: TEXT_HEADER_DISCOUNT_PRICES_AMOUNT_OFF or TEXT_HEADER_DISCOUNT_PRICES_PERCENTAGE.
$lc_text = '<table style="margin-top: 0.3em; margin-left: 1em; margin-right: 1em; margin-bottom: -1.5em; border:1px solid #94d9f8" cellspacing="0" cellpadding="3">
<tr style="background: #ECF8FD; font-weight: bold">
<td colspan="2" align="center">'.TEXT_HEADER_DISCOUNT_PRICES_ACTUAL_PRICE.'</font></td> </tr>
<tr><td align="left">' . $show_qty . '</td><td>' . $currencies->display_price($show_price, zen_get_tax_rate($products_tax_class_id)) . '</td></tr>
<tr><td align="left">' . $discount_level_1['show_qty'] . '</td><td>' . $currencies->display_price($discount_level_1['discounted_price'], zen_get_tax_rate($products_tax_class_id)) . '</td></tr>
<tr><td align="left">'. $discount_level_2['show_qty'] . '</td><td>' . $currencies->display_price($discount_level_2['discounted_price'], zen_get_tax_rate($products_tax_class_id)) .'</td></tr>
<tr><td align="left">'. $discount_level_3['show_qty'] . '</td><td>' . $currencies->display_price($discount_level_3['discounted_price'], zen_get_tax_rate($products_tax_class_id)) .'</td></tr>
<tr><td align="left">'. $discount_level_4['show_qty'] . '</td><td>' . $currencies->display_price($discount_level_4['discounted_price'], zen_get_tax_rate($products_tax_class_id)) .'</td></tr>
<tr><td align="left">'. $discount_level_5['show_qty'] . '</td><td>' . $currencies->display_price($discount_level_5['discounted_price'], zen_get_tax_rate($products_tax_class_id)) .'</td></tr></table>' ;
} else {
$lc_text ='';
}
Bookmarks