problem:
Tables 'uc_cart_products' and 'node' are joined via "nid"-field. This causes problems, if more than one revision of product node is existent. I think the correct join is via "vid"-field.

Join via "vid" is also used in uc_product_load(), see:

function uc_product_load(&$node) {
return db_fetch_object(db_query('SELECT model, list_price, cost, sell_price, weight, weight_units, length, width, height, length_units, pkg_qty, default_qty, unique_hash, ordering, shippable FROM {uc_products} WHERE vid = %d', $node->vid));
}

current join:

$data['uc_cart_products']['table']['join']['node'] = array(
'left_field' => 'nid',
'field' => 'nid',
);

improved join:

$data['uc_cart_products']['table']['join']['node'] = array(
'left_field' => 'vid',
'field' => 'vid',
);

Comments

madsph’s picture

Assigned: Unassigned » madsph
Status: Needs review » Closed (works as designed)

It is true that uc_products has a vid field, unfortunately this is not true for neither uc_cart_products or uc_order_products. So we are left with joins through nid.

abernh’s picture

If there is a product with a second revision then the only workaround I know is to delete the current and make a new product with the new values.

It can happen, that the "auto increment" values of the tables "node" and "node_revisions" differ -- in this case any new added product might get confused by ubercart.
A "fix" to that problem is to reset then the "auto increment" values of both tables to the same (a higher) value again. New products are then again displayed correct.