
Originally Posted by
haredo
@lat9, please read post #1210 & #1211 ...
The changes that I made to correct this behavior were threefold (all in /includes/functions/functions_prices.php).
Code:
////
// computes products_price + option groups lowest attributes price of each group when on
//Dual Pricing
function zen_get_products_base_price($products_id) {
global $db;
$product_check = $db->Execute("select products_price, products_price_w, products_priced_by_attribute from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
// is there a products_price to add to attributes
//Dual Pricing start
if (isset($_SESSION['customer_whole']) && $_SESSION['customer_whole'] != '0') {
$i = (int)$_SESSION['customer_whole'];
$i--;
$products_price_array = $product_check->fields['products_price_w'];
$productsprice = explode("-",$products_price_array);
$products_price = (float)$productsprice[$i];
/*-bof-20131201-lat9-removed to allow products to be wholesale for some, but not all, wholesale groups
if ($products_price == '0' || $products_price == '') {
$products_price = (float)$productsprice[0];
}
-eof-20131201-lat9 */
if ($products_price=='0'){
$products_price = $product_check->fields['products_price'];
}
} else {
$products_price = $product_check->fields['products_price'];
}
// do not select display only attributes and attributes_price_base_included is true
$product_att_query = $db->Execute("select options_id, price_prefix, options_values_price, options_values_price_w, attributes_display_only, attributes_price_base_included, round(concat(price_prefix, options_values_price), 5) as value from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and attributes_display_only != '1' and attributes_price_base_included='1'". " order by options_id, value");
//Dual Pricing end
$the_options_id= 'x';
$the_base_price= 0;
// add attributes price to price
if ($product_check->fields['products_priced_by_attribute'] == '1' and $product_att_query->RecordCount() >= 1) {
while (!$product_att_query->EOF) {
if ( $the_options_id != $product_att_query->fields['options_id']) {
$the_options_id = $product_att_query->fields['options_id'];
//Dual Pricing start
if (isset($_SESSION['customer_whole']) && $_SESSION['customer_whole'] != '0') {
$i = (int)$_SESSION['customer_whole'];
$i--;
$option_price_array = $product_att_query->fields['options_values_price_w'];
$optionprice = explode(",",$option_price_array);
$options_values_price = (float)$optionprice[$i];
/*-bof-20131201-lat9-Removed so that attributes can be wholesale-priced for some, but not all, wholesale groups
if ($options_values_price=='0' || $options_values_price==''){
$options_values_price = (float)$optionprice[0];
}
-eof-20131201-lat9 */
$the_base_price += $options_values_price;
if ($options_values_price=='0'){
$the_base_price += (($product_att_query->fields['price_prefix'] == '-') ? -1 : 1) * $product_att_query->fields['options_values_price'];
}
} else {
$the_base_price += (($product_att_query->fields['price_prefix'] == '-') ? -1 : 1) * $product_att_query->fields['options_values_price'];
}
}
//Dual Pricing end
$product_att_query->MoveNext();
}
$the_base_price = $products_price + $the_base_price;
} else {
$the_base_price = $products_price;
}
return $the_base_price;
}
and
Code:
////
// attributes final price
function zen_get_attributes_price_final($attribute, $qty = 1, $pre_selected, $include_onetime = 'false') {
global $db;
global $cart;
$attributes_price_final = 0;
if ($pre_selected == '' or $attribute != $pre_selected->fields["products_attributes_id"]) {
$pre_selected = $db->Execute("select pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_attributes_id= '" . (int)$attribute . "'");
} else {
// use existing select
}
//Dual Pricing start
if (isset($_SESSION['customer_whole']) && $_SESSION['customer_whole'] != '0') {
$i = (int)$_SESSION['customer_whole'];
$i--;
$option_price_array = $pre_selected->fields['options_values_price_w'];
$optionprice = explode(",",$option_price_array);
$options_values_price = (float)$optionprice[$i];
/*-bof-20131201-lat9-Allow attributes to be wholesale-priced for some, but not all, wholesale groups
if ($options_values_price=='0' || $options_values_price==''){
$options_values_price = (float)$optionprice[0];
}
-eof-20131201-lat9 */
$the_base_price += $options_values_price;
if ($options_values_price=='0'){
$options_values_price = $pre_selected->fields['options_values_price'];
}
} else {
$options_values_price = $pre_selected->fields['options_values_price'];
}
//Dual Pricing end
if ($pre_selected->fields["price_prefix"] == '-') {
//Dual Pricing
$attributes_price_final -= $options_values_price;
} else {
//Dual Pricing
$attributes_price_final += $options_values_price;
}
// qty discounts
$attributes_price_final += zen_get_attributes_qty_prices_onetime($pre_selected->fields["attributes_qty_prices"], $qty);
// price factor
$display_normal_price = zen_get_products_actual_price($pre_selected->fields["products_id"]);
$display_special_price = zen_get_products_special_price($pre_selected->fields["products_id"]);
$attributes_price_final += zen_get_attributes_price_factor($display_normal_price, $display_special_price, $pre_selected->fields["attributes_price_factor"], $pre_selected->fields["attributes_price_factor_offset"]);
// per word and letter charges
if (zen_get_attributes_type($attribute) == PRODUCTS_OPTIONS_TYPE_TEXT) {
// calc per word or per letter
}
// onetime charges
if ($include_onetime == 'true') {
$pre_selected_onetime = $pre_selected;
$attributes_price_final += zen_get_attributes_price_final_onetime($pre_selected->fields["products_attributes_id"], 1, $pre_selected_onetime);
}
return $attributes_price_final;
}
Bookmarks