Forums / Templates, Stylesheets, Page Layout / Quick template edit question for price and sale price

Quick template edit question for price and sale price

Locked

Started by nigel_lew on 14 Sep 2010, 11:55 PM · Views: 946

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
14 Sep 2010, 11:55 PM
#1
nigel_lew avatar

nigel_lew

New Zenner

Join Date:
Apr 2008
Posts:
17
Plugin Contributions:
0

Quick template edit question for price and sale price

Hi folks. I am trying to help someone edit something real fast located here.. http://www.outplaypoker.com/playing-cards-c-189/2009-wsop-kem-bicycle-playing-card-set-p-1792

Right now our setup looks like this:
$30.99 $27.99
Save 10% Off

I want our setup to look like:
Competitors Price: $30.99
Our Price: $27.99
Save 10% With Us!

Can't track this down to save my life.

thanks,
Nigel

15 Sep 2010, 12:34 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,741
Plugin Contributions:
56

Re: Quick template edit question for price and sale price

It's not done in a template; it's done in the pricing function. This is pretty complex logic; you might not want to modify it.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

15 Sep 2010, 1:09 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Quick template edit question for price and sale price

If all of your products will have the same setup here, you may be able to add output text around the parts of the price output. The
Save 10% Off
has to be defined in a language file, so you could alter it to
Save 10% With Us!

The .normalprice {} class that applies to the regular price is styled with a strikethrough, and you can change that in the stylesheet.

15 Sep 2010, 2:39 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Quick template edit question for price and sale price

OK, the entire price output is formatted in the function, with no possibility of modifying or interpolating in its output in tpl_product_info_display.php. The function zen_get_products_display_price($products_id) is extremely complex, and trying to modify its elements as they are being built would be dangerous. However, there is one point where the price elements are all concatenated in one statement (in two versions), and carefully adding text/formatting output there might be safe and simple enough to attempt.```php
if ($display_normal_price == 0) {
// don't show the $0.00
$final_display_price = $show_special_price . $show_sale_price . $show_sale_discount;
} else {
$final_display_price = $show_normal_price . $show_special_price . $show_sale_price . $show_sale_discount;
}

Something like```php
    if ($display_normal_price == 0) {
      // don't show the $0.00
      $final_display_price = $show_special_price . $show_sale_price . $show_sale_discount;
    } else {
      $final_display_price = 'Competitors Price: ' .$show_normal_price . '<br />Our Price: ' . $show_special_price . $show_sale_price . $show_sale_discount;
    }
```This hard-coding is not recommended practice, and it would be better to insert a constant in each of those locations and define the constant in a language file.
SHOW_NORMAL_PRICE_PRE
SHOW_SPECIAL_PRICE_PRE
15 Sep 2010, 3:08 AM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Quick template edit question for price and sale price

A way to do this in modern browsers (IE8 and newer, or pretty much all other leading browsers) is in the stylesheet with "pseudo-elements". You don't have to touch the PHP code at all, as long as the base elements have distinguishable identifiers (which the prices do).

<!--bof Product Price block -->
<h2 id="productPrices" class="productGeneral">
<span class="normalprice">$30.99 </span> <span class="productSpecialPrice">$27.99</span><span class="productPriceDiscount"><br />Our Price: 10% off</span></h2>

<!--eof Product Price block -->
.normalprice {display: block;}
.normalprice:before {content:'Competitors Price: ';}
.productSpecialPrice:before {content:'Our Price: ';}