$100 - Need module for dual pricing

Posts: 90
Joined: 01/11/2008

I want to get a price quote to have the following cart change.

I'm looking to have the ability to have two different prices for authenticated users and for guests.

I noticed the Uber has three pricing fields

The listed MSRP.
Your store's cost.
Sell price: *

So I'd like to have the ability to only show guest users the MSRP price in the cart/catalog and remove the add to cart buttons for them.

For authenticated users they would see the "Sell Price" and have full access to the cart.

Posts: 90
Joined: 01/11/2008

Here's something that looks like what I want to do but show guest users the MSRP price and hide all cart parts.

http://www.ubercart.org/forum/development/848/hide_price_unless_logged

I tried to make a new module as describe in that post and emptied the cache tables but no results.

Posts: 46
Joined: 11/22/2007

have a look at this as well...

Posts: 90
Joined: 01/11/2008

Quote:

First of all, you should open a new topic for tis, since it has nothing to do with CSV import. (Maybe an admin could move this topic?)
Second... How much different prices do you want? I'm in a simular situation, and I'm making use of the "list price" and "sell price" field available in UberCart, as I only need 2 standards.

I edited the function uc_cart_get_contents(), so the price returned gets switched based on a condition. As you can see in my test here below, I tried it with the user id of the admin and an anonymous user. The admin gets sell_price, others get list_price. of course, the if statement could also contain a role id or something else. I haven't yet continued on this code to make it descent and reusable. I'm open to any hints on how to do this the proper way Eye-wink I'll be coding on this in a few days.

$item->cost = $product->cost;
/* COWORKS EDIT */
global $user;
if($user->uid == 1){
$item->price = $product->sell_price;
}else{
$item->price = $product->list_price;
}
//$item->price = $product->sell_price; // this was the original line there
$item->weight = $product->weight;
$item->data = unserialize($item->data);

As this is sort of the "root" function for the prices mentioned in the cart and checkout, the switch here is taken all the way in to the order process.
I hope this kind of helps, if you need more then 2 prices, I don't think there's a module available for that right now. A lot also depends on the fact if you want different prices without any key between them or let's say a vast discount of x % or y $. In the latter, you might find results in the discounts module (which I have no experience with.)

Is this used as an over ride or do I modify one of the core cart files "uc_cart.module"

Thanks for the info

Posts: 90
Joined: 01/11/2008

I tried the above and still get the same price for all users which is the sell price. I modified the us_cart.module file

Posts: 46
Joined: 11/22/2007

The condition in this test code is set to admin user or not.

if($user->uid == 1){
$item->price = $product->sell_price;
}else{
$item->price = $product->list_price;
}

If you want it set to a specific role, you'll need something like this:

global $user;
if(in_array("name_of_your_role", $user->roles)){
$item->price = $product->sell_price;
}else{
$item->price = $product->list_price;
}

Posts: 1
Joined: 02/16/2008

Our company who already implemented several Ubercart webstores recently had 2 clients requesting the same thing. We developed a Drupal/Ubercart module which allows you to :

1. Define roles which should have a custom selling price field (In the store admin settings)
2. For each defined role on the Add/edit product page the possibility to specify the selling price for that role. If no price is specified, the default selling price is used.

We're still testing it (still need to test discounts and some other stuff), but the code works nicely.

If you like I can put up the module in the contributions section as soon as our basic testing has been completed (probably within this week). The only thing (of course) I ask if that if you find any errors, to let me know about them so we can improve the module.

I'll follow up to this thread when the module is added to the contributions section.

Geoffrey

Posts: 4368
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

That would be awesome Geoffrey. Thanks for letting us know. Smiling

Posts: 90
Joined: 01/11/2008

Thats pretty cool and will definitely look forward to testing and running the module.

Thank You.

Posts: 2
Joined: 03/07/2008

Thanks, I used your code and also mixed it in with the Ajax Attribute Calculations Module so that the prices are updated dynamicly and the discount price is displayed, not just in the cart, but also on the product view.

Here's the first part of the Calculate_Price() function with my (few) changes:

function _calculate_price() {
drupal_set_header("Content-Type: plain/text; charset=utf-8");
$field_values = $_POST;
$correct_token = drupal_get_token($field_values['uccp']['field_id']);
$nid = $field_values['uccp']['nid'];
if ($correct_token == $field_values['uccp']['form_token']) {
$result = db_query('SELECT sell_price, list_price FROM {uc_products} WHERE nid=%d AND vid=(SELECT vid FROM {node} WHERE nid=%d)', $nid, $nid);
if ($product = db_fetch_object($result)) {
global $user;
if(in_array("discount user", $user->roles)){
$price = $product->list_price;
}else{
$price = $product->sell_price;
}
//$price = $product->sell_price;
}

Posts: 90
Joined: 01/11/2008

gdevlugt did you have a chance to test out your price mod?

Thanks
Arek

Posts: 4
Joined: 04/17/2008

I am not sure where to find the _calculate_price() function. Can you direct me on that?

Posts: 284
Joined: 11/19/2007
Bug FinderGetting busy with the Ubercode.

rockcandy, that function is in the Ajax Attribute Calculations module (http://drupal.org/project/uc_aac) or at least it used to be. The module has since been updated and contains a similar function which is more appropriately named _uc_aac_calculate_price(). Not sure if you'll still be able to do the code replacement that was suggested within the updated module though...

Posts: 90
Joined: 01/11/2008

Well I have had no luck integrating the two examples I found on here so I got $100 to anyone who can write/maintain a module that will do the following.

Give me the ability to turn off the price and the buy it button as well as limit cart access to anonymous users and show the list price to them. Once a user with a specific role logs in (ie wholesale) then the price changes to the regular price and the add to cart button becomes activated.

Posts: 79
Joined: 08/09/2007
Bug Finder

I can write this module for you today or tomorrow.

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 90
Joined: 01/11/2008

Hi Replied to PM already Smiling

Posts: 79
Joined: 10/29/2007
Bug Finder

I'm looking for a mod that will allow me to have wholesale pricing for my products as well.

Posts: 90
Joined: 01/11/2008

This is in the works right now and will post back when the module has been tested out,

Posts: 90
Joined: 01/11/2008

I have the first version of this module but its still being worked/written. I've tested it out and will be at least for me exactly what I need for a wholesale company, which only wants to sell to retailers but use the catalog to display items to the public with out the public being able to order.

Access to cart/product features will also be accessible on a role by role basis.

Posts: 79
Joined: 10/29/2007
Bug Finder

Does your module add a special price field for wholesalers, or just use the current sell_price field (or use a percentage).

I need the ability to have a seperate price for items that are marked as wholesale so that members with that role get a lower price than normal members.

Posts: 90
Joined: 01/11/2008

It'll use the default pricing fields and you'll just be able to turn them off per role. So for me anonymous users will see the List Price (MSRP) and won't see the buy it button while retailer role users will see the Sell Price and have full cart access.

Posts: 79
Joined: 08/09/2007
Bug Finder

Thanks for the sponsorship end user. The module has been contributed.
http://www.ubercart.org/contrib/4790

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 90
Joined: 01/11/2008

Thanks Kai

This module works fine with the stock UC catalog/product page setup but for those using a custom template like the Nifty Product Tutorial http://www.ubercart.org/forum/development/3868/nifty_products_tutorial_p... You'll need to make some small modification to your template. You will need to check for '#access' in the template.

Normally you would use something link this to print the product info to the template

<?php print $node->content['sell_price']["#value"]; ?>

In order for the module to work properly and allow/disallow access to product info you'll have to something like this

<?php if($node->content['sell_price']["#access"]) { print $node->content['sell_price']["#value"];} ?>

Arek

Posts: 8
Joined: 06/19/2008

This module works, but it only shows or not these prices, but when you add something in the cart, there always goes sell price. The issue was user with specific roles not only to see their price, but to buy products on list price for example.

Posts: 90
Joined: 01/11/2008

Well the module was actually designed for my needs for a wholesale company so might not work for what you need. I needed to show a different price (MSRP) for anonymous users, disable the order system for anonymous and when a retailer/distributor logs in they would see the sell price and order at that price.