Sell price striked through when less than list price

Posts: 19
Joined: 04/08/2008

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!

Posts: 64
Joined: 02/13/2008
Posts: 19
Joined: 04/08/2008

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.

Posts: 72
Joined: 02/14/2008
Bug FinderGetting busy with the Ubercode.Internationalizationizer

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

Posts: 19
Joined: 04/08/2008

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

Posts: 72
Joined: 02/14/2008
Bug FinderGetting busy with the Ubercode.Internationalizationizer

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

Posts: 19
Joined: 04/08/2008

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

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

Posts: 19
Joined: 04/08/2008

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

Posts: 72
Joined: 02/14/2008
Bug FinderGetting busy with the Ubercode.Internationalizationizer

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.

Posts: 19
Joined: 04/08/2008

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