9 replies [Last post]
gabble's picture
Offline
Joined: 04/08/2008
Juice: 54
Was this information Helpful?

Suppose we have:

List Price: $100.00
Sell Price: $ 95.00

I would like the price be displayed like the following in the product page and in the catalog page:

$ 100.00
$95.00

This should be done automatically whenever the sell price is less than the list price.
When the list price equals the sell price, only the sell price should be displayed.

How can accomplish this?

Thanks in advance for your kind support!

mykz-'s picture
Offline
Joined: 02/13/2008
Juice: 203
This might help. Nifty

This might help.

Nifty Products Tutorial Part 1
http://www.ubercart.org/forum/development/3868/nifty_products_tutorial_p...

gabble's picture
Offline
Joined: 04/08/2008
Juice: 54
Re: This might help. Nifty

Thanks for pointing me that great tutorial!

I added the following lines to my own node-product.tpl.php:

<?php
if ($sell_price < $list_price) {
  print
"<div id=\"price_box\" class=\"low-price-box\"><p class=\"list_price striked\">" . $list_price . "</p><p class=\"sell_price offer\">" . $sell_price . "</p><p class=\"offer_text\">Low price!</p></div>";
  }
  else {
    print
"<div id=\"price_box\"><p class=\"sell_price\">" . $sell_price . "</p></div>";
  }
?>

Then I used CSS to style:

#price_box
.low-price-box
.list_price
.striked
.sell_price
.offer
.offer_text

There is one big problem, though: I use this contrib http://www.ubercart.org/contrib/1532 (in Europe item prices must include taxes). With such module enabled, the code above only works for user #1, while other users display price including VAT, so my code doesn't apply.

I am no code guru, so I would appreciate if someone could tell me how to fix my code.

TIA, gabble.

Al
Al's picture
Offline
Bug FinderGetting busy with the Ubercode.Internationalizationizer
Joined: 02/14/2008
Juice: 249
List price & VAT

Hi gabble,

I don't use uc_taxes_price anymore, so please forgive me if I should miss something. The easiest way IMO is to add support for taxed List price in uc_taxes_price. As far as I remember there are just 3 places with 2 lines where you find code like (they are not exactly the same, so copy each!)

        $sell_price = $node->sell_price + ($node->sell_price * _uc_product_taxes_calculate($node));
        $node->sell_price = round($sell_price, 2);

Search with your editor for "sell_price", copy the lines and in the copy replace "sell_price" through "list_price", so the result is that List and Sell price have again the same tax conditions.

Hope this helps, Al

gabble's picture
Offline
Joined: 04/08/2008
Juice: 54
Re: List price & VAT

Just to be sure I got it right...

a) at line 23 I have to replace:

$sell_price = $node->sell_price / (1 + _uc_product_taxes_calculate($node));
$node->sell_price = round($sell_price, 2);

with:

$sell_price = $node->list_price / (1 + _uc_product_taxes_calculate($node));
$node->list_price = round($sell_price, 2);

b) at line 28 I have to replace:

$sell_price = $node->sell_price + ($node->sell_price * _uc_product_taxes_calculate($node));
$node->sell_price = round($sell_price, 2);

with:

$sell_price = $node->list_price + ($node->list_price * _uc_product_taxes_calculate($node));
$node->list_price = round($sell_price, 2);

c) at line 63:
$display_price = ', '. uc_currency_format($node->sell_price + $option->price);
with:
$display_price = ', '. uc_currency_format($node->list_price + $option->price);

d) at line 113:
$item->price = $product->sell_price;
with:
$item->price = $product->list_price;

Is it all right??

Thanks for your time, Al!
gabble

Al
Al's picture
Offline
Bug FinderGetting busy with the Ubercode.Internationalizationizer
Joined: 02/14/2008
Juice: 249
Re: List price & VAT

So I took a quick look into it. Sorry, I wasn't clear enough. Not replace, but add the same procedure for List price. You don't want to loose the tax for Sell price. And you need just a) and b).

So after the change line 23-26 look like this:

<?php
$list_price
= $node->list_price / (1 + _uc_product_taxes_calculate($node));
$node->list_price = round($list_price, 2);
$sell_price = $node->sell_price / (1 + _uc_product_taxes_calculate($node));
$node->sell_price = round($sell_price, 2);
?>

line 30-33 will be new:

<?php
$list_price
= $node->list_price + ($node->list_price * _uc_product_taxes_calculate($node));
$node->list_price = round($list_price, 2);
$sell_price = $node->sell_price + ($node->sell_price * _uc_product_taxes_calculate($node));
$node->sell_price = round($sell_price, 2);
?>

c) not, display price is the sell price, so this stays
d) also not

Try it, I am quite sure this two chances where everything you need.

Best regards Al

gabble's picture
Offline
Joined: 04/08/2008
Juice: 54
Re: Re: List price & VAT

That seems to work, a huge thank you!!!!

Now we should submit the fix to the author, I guess… Eye-wink

gabble's picture
Offline
Joined: 04/08/2008
Juice: 54
Re: Re: Re: List price & VAT

Uhm, I probably spoke too soon:

Fatal error: Call to undefined function _uc_cart_product_get_options() in [my-path-to]/modules/ubercart/contrib/uc_taxes_price/uc_taxes_price.module on line 115

This happens everytime a user (apart from user #1) clicks "add to cart" with uc_taxes_price enabled.

Do you think it could be related to the modifications we have made to the module?

Sad
Gabble

Al
Al's picture
Offline
Bug FinderGetting busy with the Ubercode.Internationalizationizer
Joined: 02/14/2008
Juice: 249
Fatal error: undefined function

Hi Gabble, sure not.

uc_taxes_price is dependent on the Attribute module (core) even if it is not used, so go to admin/build/modules, in Ubercart - core(optional) you have to activate Attribute.

gabble's picture
Offline
Joined: 04/08/2008
Juice: 54
Re: Fatal error: undefined function

Uh, that's right! Thank you once again! Smiling