Active
Project:
Ubercart Price Per Role
Version:
6.x-1.1
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jan 2011 at 03:13 UTC
Updated:
28 Apr 2014 at 15:17 UTC
Jump to comment: Most recent
this is my code:
$product = node_load($product_id);
$product->attribute1 = 'example';
node_save($product );
when this code being called , the real sell_price data in database has been changed to current user's role price.
i think this is bug ,because many other modules called node_load, node_save.it does not works as your expectation.
the coresponding code in uc_price_per_role module is:
$original_price = $node->sell_price;
$price = uc_price_per_role_find_price($prices);
if ($price !== FALSE) {
$node->sell_price = $price;
}
Comments
Comment #1
fuzzydru commentedI have the same issue using version 5.1.3. Once a user with a role associated with a "role price" edits a product the product "sell price" gets saved with the "role price" value.
The only thing I can see altering the $node->sell_price is in line 232:
Does anyone know how to avoid this error?
Comment #2
Saoirse1916 commentedSubscribing
Comment #3
rferguson commentedNOTE**: This is for Drupal 7 only, but a similar fix could be applied in the right place for 6.
I've come across this same thing and have fixed the issue with a small module. Contents of the module is:
What it's doing is the same thing the module already does for hook_node_prepare (sets the sell price to be correct for node edit page). While doing node_save on your own, this isn't happening and the role's price is overwritten. This keeps it the same as if saving from the edit page while using node_save. Confirmed works with Views bulk operations as well (which basically just calls node_save as well).