</td> // Dual Pricing start <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED_W; ?> </td> // Dual Pricing end <?php } ?> </tr> <?php $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']); $display_price = zen_get_products_base_price($_GET['products_filter']); // Dual Pricing start $display_price_w = zen_get_products_base_price_w($_GET['products_filter']); // Dual Pricing end $display_specials_price = zen_get_products_special_price($_GET['products_filter'], false); // $display_sale_price = zen_get_products_special_price($_GET['products_filter'], false); for ($i = 0, $n = sizeof($discount_name); $i < $n; $i++) { switch ($pInfo->products_discount_type) { // none case '0': $discounted_price = 0; break; // percentage discount // percentage discount case '1': if ($pInfo->products_discount_type_from == '0') { $discounted_price = $display_price - $display_price * ($discount_name[$i]['discount_price'] / 100); // Dual Pricing start
function zen_get_products_special_price($product_id, $specials_price_only = false) { global $db; $product = $db->Execute("select products_price, products_model, products_priced_by_attribute from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "'"); if ($product->RecordCount() > 0) { // $product_price = $product->fields['products_price']; $product_price = zen_get_products_base_price($product_id); } else { return false; } // Dual Pricing start if ($product->RecordCount() > 0) { // $product_price = $product->fields['products_price']; $product_price = zen_get_products_base_price_w($product_id); } else { return false; } // Dual Pricing end $specials = $db->Execute("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int) $product_id . "' and status='1'"); if ($specials->RecordCount() > 0) { // if ($product->fields['products_priced_by_attribute'] == 1) { $special_price = $specials->fields['specials_new_products_price']; } else { $special_price = false; } if (substr($product->fields['products_model'], 0, 4) == 'GIFT') { //Never apply a salededuction to Ian Wilson's Giftvouchers if (zen_not_null($special_price)) { return $special_price; } else { return false; } } // return special price only if ($specials_price_only == true) { if (zen_not_null($special_price)) { return $special_price; } else { return false; } } else { // get sale price // changed to use master_categories_id // $product_to_categories = $db->Execute("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); // $category = $product_to_categories->fields['categories_id']; $product_to_categories = $db->Execute("select master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'"); $category = $product_to_categories->fields['master_categories_id']; $sale = $db->Execute("select sale_specials_condition, sale_deduction_value, sale_deduction_type from " . TABLE_SALEMAKER_SALES . " where sale_categories_all like '%," . $category . ",%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0001-01-01') and (sale_date_end >= now() or sale_date_end = '0001-01-01') and (sale_pricerange_from <= '" . $product_price . "' or sale_pricerange_from = '0') and (sale_pricerange_to >= '" . $product_price . "' or sale_pricerange_to = '0')"); if ($sale->RecordCount() < 1) { return $special_price; } if (!$special_price) { $tmp_special_price = $product_price; } else { $tmp_special_price = $special_price; } switch ($sale->fields['sale_deduction_type']) { case 0: $sale_product_price = $product_price - $sale->fields['sale_deduction_value']; $sale_special_price = $tmp_special_price - $sale->fields['sale_deduction_value']; break; case 1: $sale_product_price = $product_price - $product_price * $sale->fields['sale_deduction_value'] / 100; $sale_special_price = $tmp_special_price - $tmp_special_price * $sale->fields['sale_deduction_value'] / 100; break; case 2: $sale_product_price = $sale->fields['sale_deduction_value']; $sale_special_price = $sale->fields['sale_deduction_value']; break; default: return $special_price; } if ($sale_product_price < 0) { $sale_product_price = 0; } if ($sale_special_price < 0) { $sale_special_price = 0; } if (!$special_price) { return number_format($sale_product_price, 4, '.', ''); } else { switch ($sale->fields['sale_specials_condition']) { case 0: return number_format($sale_product_price, 4, '.', ''); break; case 1: return number_format($special_price, 4, '.', ''); break; case 2: return number_format($sale_special_price, 4, '.', ''); break; default: return number_format($special_price, 4, '.', ''); } } } }