kshop Posted July 17, 2004 Posted July 17, 2004 I have just tried Total B2B contribution.everything worked except the price shown to the customer was wrong. After hours of debugging I have found the problem is how osCommerce handles nulls, i.e. it uses 0 instead of null so the following query produces invalid results when there are no manufacturer assigned to the product (manufacturers=0 instead of null), so ALL products with no manufacturer specified get a default discount which may result in losses. I'm not a PHP programmer, however I have some SQL knowledge and I think it should be fixed some time in the OC future releases. It is just a one example, it may be that more such "features" are hidden in the OC $query_C = tep_db_query("select m.manudiscount_discount from " . TABLE_MANUDISCOUNT . " m, " . TABLE_PRODUCTS . " p where m.manudiscount_groups_id=0 /*should be "is null" not a "=0"*/ and m.manudiscount_customers_id=0 and p.products_id = '" . $products_id . "' and p.manufacturers_id = m.manudiscount_manufacturers_id"); I'm posting to the general forum, because I think it's a general problem which relates to this particular (and great) contribution...
Acheron Posted July 17, 2004 Posted July 17, 2004 function tep_not_null($value) { if (is_array($value)) { if (sizeof($value) > 0) { return true; } else { return false; } } else { if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) { return true; } else { return false; } } } You can change the function in general.php if you'd like so it will operate as needed.
kshop Posted July 17, 2004 Author Posted July 17, 2004 I mean that it seems OC database uses '0' instead of NULL which may (and may not) sometimes result in unexpected problems as in the case above. Just one example: if (ACCOUNT_STATE == 'true') { if ($entry_zone_id > 0) { $sql_data_array['entry_zone_id'] = $entry_zone_id; $sql_data_array['entry_state'] = ''; } else { $sql_data_array['entry_zone_id'] = '0'; // <--- shouldn't be NULL here? $sql_data_array['entry_state'] = $entry_state; } }
Acheron Posted July 17, 2004 Posted July 17, 2004 Actually, the default for the table is '0' not NULL. I would think this field cannot be NULL which is why the code above was used. Suburb, state, and company on the other hand are NULL by default. I can of course think of instances where NULL would be the proper thing to use (and I have used it in a number of my osC mods) but I haven't come across anything in the stock osC that would cause a problem. What you have posted above is from a contribution and as you may already know, the quality of those varies greatly. ;) btw, why is manudiscount_groups_id NULL in the 1st place? Just curious. :)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.