Hi
Making good progress in learning code and creating my website on Localhost. I have some products which are services and have no price, so I want to hide the price in template/product/Product.tpl ihave altered the code as follows:
After line 146 <ul class="list-unstyled">
I have added:
<h2> <?php if($price == "£0.00") { echo "Contact re cost"; } else { echo $price;} ?> </h2>
To give the following in context:
<?php if ($price) { ?>
<ul class="list-unstyled">
<h2> <?php if($price == "£0.00") { echo "Contact re cost"; } else { echo $price;} ?> </h2>
<?php if (!$special) { ?>
<li>
<h2><?php echo $price; ?></h2>
</li>
This Produces:
£0.00
£0.00
in Product panel.
I have tried other variations and either get code errors are the result above. What am I doing wrong?
As always help appreciated.
Add a var_dump to see what exactly you need to validate against.
Code: Select all
var_dump($price);
You look at wrong place.
The price is already formatted with currency sign, what happen if user change the currency to $ ?
Best way to check is at controller/product/product.php find $data['price'], that is where $price come from.
Add some test code, to change price into text FREE
Be aware code above not check special price!
Other alternative is make new variable as an anchor for front template
And use them at template
Hope that help
The price is already formatted with currency sign, what happen if user change the currency to $ ?
Best way to check is at controller/product/product.php find $data['price'], that is where $price come from.
Add some test code, to change price into text FREE
Code: Select all
if ($this->config->get('config_customer_price') ... ) {
$data['price'] = $this->currency->format(...);
} else {
$data['price'] = false;
}
// Add new code as a test!
if (!(int)$product_info['price']) {
$data['price'] = 'FREE';
}
Other alternative is make new variable as an anchor for front template
Code: Select all
if (!(int)$product_info['price']) {
$data['isFree'] = true;
} else {
$data['isFree'] = false;
}
Code: Select all
<?php if ($isFree) { ?>
- Show free image (?)
- Ignore special price
<?php } else { ?>
echo $price;
echo $special;
<?php } ?>
Who is online
Users browsing this forum: No registered users and 5 guests