24 replies [Last post]
end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Was this information Helpful?

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.

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Need quote for dual pricing

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.

kcoworks's picture
Offline
Joined: 11/22/2007
Juice: 103
have a look at this as

have a look at this as well...

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Quote:
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

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Quote:

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

kcoworks's picture
Offline
Joined: 11/22/2007
Juice: 103
Re: Re: Quote:

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;
}
jaredthane's picture
Offline
Joined: 03/07/2008
Juice: 4
Works Great!

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;
}

rockcandy's picture
Offline
Joined: 04/17/2008
Juice: 11
what file has _calculate_price()?

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

cYu
cYu's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 11/19/2007
Juice: 850
Re: what file has _calculate_price()?

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...

gdevlugt's picture
Offline
Joined: 02/16/2008
Juice: 2
Re: Need quote for dual pricing

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Need quote for dual pricing

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

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Re: Need quote for dual pricing

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

Thank You.

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Re: Need quote for dual pricing

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

Thanks
Arek

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Need quote for dual pricing

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.

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: Re: Need quote for dual pricing

I can write this module for you today or tomorrow.

Biodiesel * (ubercart + drupal) = Sundays Energy

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Re: Re: Need quote for dual pricing

Hi Replied to PM already Smiling

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: Re: Need quote for dual pricing

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

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Re: Re: Re: Re: Need quote for dual pricing

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

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Re: Re: Re: Re: Re: Need quote for dual pricing

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.

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: Re: Re: Re: Re: Need quote for dual pricing

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.

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Re: Re: Re: Re: Re: Re: Re: Need quote for dual pricing

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.

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: $100 - Need module for dual pricing

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

Biodiesel * (ubercart + drupal) = Sundays Energy

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Thanks Kai This module works

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

sashomi's picture
Offline
Joined: 06/19/2008
Juice: 29
Field premissions

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.

end user's picture
Online
Joined: 01/11/2008
Juice: 1196
Re: Field premissions

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.