ubercart price per role
[07.06.2013 18:56:43] Alexander Yakovenko (PaFFeN): Good day! Sorry to bother you again, I have a question and would really appreciate your help.
[07.06.2013 18:56:56] Lev Myshkin: Hello.
[07.06.2013 18:57:02] Alexander Yakovenko (PaFFeN): There are two prices on the site; how can I set it up so that one role buys at one price and another role buys at a different price?
[07.06.2013 18:57:08] Alexander Yakovenko (PaFFeN): I'm building the site on Ubercart.
[07.06.2013 18:57:11] Alexander Yakovenko (PaFFeN): Drupal 7.
[07.06.2013 18:57:18] Lev Myshkin: There is a module called price per role.
[07.06.2013 18:57:31] Alexander Yakovenko (PaFFeN): To clarify, there are wholesale buyers and retail buyers.
[07.06.2013 19:00:50] Alexander Yakovenko (PaFFeN): Thank you.
[07.06.2013 20:12:48] Alexander Yakovenko (PaFFeN): <?php print render($content['cost']); ?>
<?php print render($content['sell_price']); ?>
I have another question; here I am displaying two fields with prices in the node.
[07.06.2013 20:13:07] Alexander Yakovenko (PaFFeN): I don't understand why the site admin sees the cost field but an anonymous user does not?
[07.06.2013 20:13:29 | Edited 21:09:14] Alexander Yakovenko (PaFFeN): Even a regular manager cannot see the cost field either.
[07.06.2013 21:08:49] Alexander Yakovenko (PaFFeN): Help.
[07.06.2013 21:09:02] Alexander Yakovenko (PaFFeN): (tmi)
[07.06.2013 21:09:14] Lev Myshkin: Ah, what? sell_price is the purchase price of the product; it shouldn't be shown to anyone.
[07.06.2013 21:09:37] Lev Myshkin: cost is what is displayed to the user.
[07.06.2013 21:09:43] Lev Myshkin: Although I could be wrong.
[07.06.2013 21:09:47] Alexander Yakovenko (PaFFeN): There are indeed two prices: cost and sell_price.
[07.06.2013 21:09:53] Alexander Yakovenko (PaFFeN): It's actually the other way around.
[07.06.2013 21:10:07] Alexander Yakovenko (PaFFeN): sell_price is the mandatory price.
[07.06.2013 21:10:27] Alexander Yakovenko (PaFFeN): while cost is additional.
[07.06.2013 21:10:45] Alexander Yakovenko (PaFFeN): And I don't understand why when I log in as an admin, I can see both fields,
[07.06.2013 21:10:55] Alexander Yakovenko (PaFFeN): but as a regular manager, the cost field is not visible.
[07.06.2013 21:13:33] Lev Myshkin: Maybe permissions can be added?
[07.06.2013 21:13:53] Alexander Yakovenko (PaFFeN): I checked, it's empty and not much there.
[07.06.2013 21:14:41] Lev Myshkin: Why do you need the additional price?
[07.06.2013 21:15:02] Lev Myshkin: Can't it be replaced with a field?
[07.06.2013 21:15:05] Alexander Yakovenko (PaFFeN): Well, the point is that there are two prices: one for wholesalers and another for retail.
[07.06.2013 21:15:24] Lev Myshkin: Didn't price per role work for you?
[07.06.2013 21:15:37] Alexander Yakovenko (PaFFeN): It worked, but not entirely.
[07.06.2013 21:16:00] Alexander Yakovenko (PaFFeN): It outputs the main price into the sell_price variable.
[07.06.2013 21:17:18] Alexander Yakovenko (PaFFeN): http://clip2net.com/s/5bTiwB
[07.06.2013 21:18:09] Alexander Yakovenko (PaFFeN): http://clip2net.com/s/5bTkaN
[07.06.2013 21:18:16] Alexander Yakovenko (PaFFeN): Here’s the essence: in the first screenshot, the admin is shown.
[07.06.2013 21:18:23] Alexander Yakovenko (PaFFeN): In the second, the wholesaler.
[07.06.2013 21:18:54 | Edited 21:19:58] Alexander Yakovenko (PaFFeN): So, the cost field disappears for the wholesaler, and sell_price shows the price indicated through the price_per module.
[07.06.2013 21:19:00] Lev Myshkin: Wouldn't it be easier to make it an additional field?
[07.06.2013 21:19:06] Lev Myshkin: Will they be buying wholesale from the site?
[07.06.2013 21:19:22] Lev Myshkin: Surely wholesalers will just look at the site and then ask for an invoice.
[07.06.2013 21:20:07] Alexander Yakovenko (PaFFeN): There will be online payment via Privat24.
[07.06.2013 21:20:17] Alexander Yakovenko (PaFFeN): That's why I needed the price per module.
[07.06.2013 21:20:40] Alexander Yakovenko (PaFFeN): But it overwrites the sell_price variable.
[07.06.2013 21:20:51] Alexander Yakovenko (PaFFeN): I need both prices to be visible to the wholesaler: retail and their price.
[07.06.2013 21:21:24] Lev Myshkin: You probably need to write custom code in node.tpl.php to display these two prices.
[07.06.2013 21:21:51] Lev Myshkin: Because price per role intentionally hides the other prices. It only shows for its own role.
[07.06.2013 21:22:02] Alexander Yakovenko (PaFFeN): Exactly!!!!!
[07.06.2013 21:22:08] Lev Myshkin: We need to look at the $node object, all prices
[07.06.2013 21:22:08] Alexander Yakovenko (PaFFeN): There's another one in the sidebar
[07.06.2013 21:22:34] Alexander Yakovenko (PaFFeN): But even if we don't use the per module, the cost price isn't visible
[07.06.2013 21:23:24] Alexander Yakovenko (PaFFeN): Here's the code I'm using in node--product.tpl
[07.06.2013 21:23:26] Alexander Yakovenko (PaFFeN): <!-- retail price --><div class="sell-price-bckg">
<?php print render($content['sell_price']); ?>
<?php print render($content['field_retail_sale']); ?>
</div>
<!--END retail price -->
<!-- wholesale price for registered users -->
<?php if ($logged_in): ?><div class="opt-price-bckg">
<?php print render($content['field_price_opt_sale']); ?>
<?php print render($content['cost']); ?>
</div>
<?php else: ?>
<div class="register-price-opt"><strong>Wholesale price:</strong><br><span class="text-refister-price-opt">Available after <a href="/user/register">registration</a></span></div>
<?php endif; ?>
<!--END wholesale price for registered users -->
[07.06.2013 21:27:47] Lev Myshkin: Is there anything related to price in the $node variable?
[07.06.2013 21:28:18] Alexander Yakovenko (PaFFeN): [list_price] => 950.00000
[cost] => 950.00000
[sell_price] => 1050.00000
[07.06.2013 21:28:32 | Edited 21:28:33] Lev Myshkin: Well then, let's output from $node
[07.06.2013 21:28:46] Alexander Yakovenko (PaFFeN): Example
[07.06.2013 21:28:48] Alexander Yakovenko (PaFFeN): Pleaseee
[07.06.2013 21:29:07] Lev Myshkin: print $node->cost
[07.06.2013 21:29:26] Lev Myshkin: Print it using dsm($node)
[07.06.2013 21:29:47] Lev Myshkin: There you can click on the required field and copy how to access the field directly
[07.06.2013 21:30:22] Lev Myshkin: Of course, you'll have to use number_format() to remove a bunch of zeros
[07.06.2013 21:30:40] Alexander Yakovenko (PaFFeN): I understood that already, the zeros are floating around
[07.06.2013 21:36:56] Alexander Yakovenko (PaFFeN): It's strange, but why doesn't it output when using <?php print render($content['cost']); ?>
[07.06.2013 21:37:05] Alexander Yakovenko (PaFFeN): <?php print $node->cost; ?>
[07.06.2013 21:37:08] Alexander Yakovenko (PaFFeN): This outputs
[07.06.2013 21:37:25] Lev Myshkin: render() is a Drupal function; it checks permissions when outputting
[07.06.2013 21:37:46] Lev Myshkin: You can check how it works on api.drupal.org
[07.06.2013 21:37:49] Alexander Yakovenko (PaFFeN): http://clip2net.com/s/5bTN0I the wholesale label disappears
[07.06.2013 21:38:12] Lev Myshkin: Manually check the role and output based on the role directly in the template
[07.06.2013 21:38:15] Alexander Yakovenko (PaFFeN): Right, it doesn't see it
[07.06.2013 21:38:32] Alexander Yakovenko (PaFFeN): Is there an example of the check?
[07.06.2013 21:39:02] Lev Myshkin: global $user;
if(in_array('opt', $user->roles)){
}
[07.06.2013 21:39:15] Lev Myshkin: The parameters might need to be different in the function
[07.06.2013 21:40:18] Alexander Yakovenko (PaFFeN): Okay, I'll try now
[07.06.2013 21:40:28] Alexander Yakovenko (PaFFeN): Thank you for your help
[07.06.2013 21:40:33] Alexander Yakovenko (PaFFeN): It's just invaluable
[07.06.2013 21:40:49] Lev Myshkin: You're welcome, I'll move it to the forum later
[07.06.2013 21:41:20] Alexander Yakovenko (PaFFeN): No problem!
[07.06.2013 21:41:33 | Edited 21:41:39] Alexander Yakovenko (PaFFeN): I'm also on the forum, but it takes a long time
[07.06.2013 21:41:56] Alexander Yakovenko (PaFFeN): There's no time, but here we quickly resolved the issues together