Following the instructions on Different role prices. Do you think is a good solution? I've rewritten that implementation using a new function uc_product_get_price wrapping $product->sell_price and $node->sell_price.

Here's two patches against 5.x-1.3 version to apply on uc_product and uc_cart modules. Since I've problems following smoothly these steps, I centralized the user role control in that function. I've added a global variable to store the "discount user role" (the role that uses cost instead price as sell price).

Note #1: I see uc_product_get_price is a commented function using $node->nid instead the entire node object. A supplemental control statement could make it compatible to commented function, but I passed the object (product or node) as reference for performance reason.
Note #2: I haven't yet tried to implement phethean uc_attribute.module modifications. If anyone wants to add this please attach the patch (you can use this function passing 'attribute' type).

I've marked these patches as "code needs work" because Note #2 and the use of a global variable instead a GUI-based role selection.

Comments

if and a’s picture

Hi, i'm interested in this issue now. thank you for patches it's working for me but it doesn't display the right price in my ubercart catalog. is there any chance how to do it?

chirale’s picture

StatusFileSize
new739 bytes

Hi, you have to change all $product->sell_price to uc_product_get_price($product).

This is also valid for product $node and, if 'attribute' type is passed as 2nd argument to uc_product_get_price, It should be valid for attribute (not implemented yet).

Patch for Catalog attached.

chirale’s picture

Status: Needs work » Needs review

One month passed, set to "needs review".

Island Usurper’s picture

Status: Needs review » Needs work

I think getting the discounted price for attributes should be a separate function since they're governed by a separate module. I'm also not happy with a global variable. At the very least, it can be the default value of a variable_get() call. There are also a lot more places that the product price is used, and you don't always apply the discount because of the current user. Often times, it's the user who placed the order, not the administrator updating or fulfilling the order.

rszrama’s picture

Status: Needs work » Closed (won't fix)

In general, I think a function that calculates a product price is a good idea... however, I think a more robust solution is needed that doesn't have the goal of "different role prices" in mind but rather exposes a hook that a module could use to alter prices based on role. To that end, I think we should concentrate our efforts on this code: http://www.ubercart.org/forum/development/6995/vatgst_overview

We're not really tracking feature requests through this tracker, so I'm going to mark this as "won't fix" - also, I'm doing that because I don't believe this should be core functionality but rather part of a discounts package.

mtraherne’s picture

Have you tried this module:

http://drupal.org/project/uc_price_per_role

I have installed it and it works perfectly straight out of the box. It simply adds a new "[role] price" to all existing products. You can choose which roles you want to set this up for and supply a price for all roles.

Works perfectly on Drupal 5.x and Ubercart 1.x

doublejosh’s picture

Yeah, but then you have to go set a new price on all your products, rather than configuring 20% for members, etc.