So from the includes/functions/functions_prices.php file from within zen_get_products_specials_price there is the following code which pulls up sale information about/for the given product. The if statement has been "reversed" so that it identifies that a sale is present as compared to the ZC version that asks if there is nothing (<1) to identify that a sale is not present.
There is other logic throughout ZC that identifies how that sale data is to be used, typically pairing the function with itself but changing the last parameter. Reason for that if not mistaken is to identify how the results from both calls are to be used/applied (ie, if there is a special, if there is a sale, if there are both or obviously neither).
Code:
$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() > 0) {
// the product is within a sale condition
} else {
// the product does not exist in a sale condition at the moment.
}
Depending on how this is being used, could replace the first two lines of code with a single ZC function:
Code:
$category = zen_get_products_category_id($product_id);
Or substitute that function (right hand side without the semicolon) where $category is already used...
Bookmarks