Hi, David,
how can I make the search bar found on the productsmap.php page longer? Sometimes I write articles that have long names and that's a problem. Thanks.
Excuse me, I explained myself badly. I'm talking about the string or box that manages to cover a few words and every time I have to scroll through it.
Hi Tobix,
You can make the select box much wider; it's in admin/helper.php at line 105 where you'll find the style attribute of the select element...
style='width:100%;height:110px;'
width:100% will set it to the width of the foundation small-6 columns container but you could use a fixed much wider width and it will overflow e.g;
style='width:800px;height:110px;'
Cheers,
David.
--
PriceTapestry.com
I changed but I'm going to change the box of another content. I need to edit this /admin/productsmap.php file
is the box is called "Name". Where you write the name of the article to be mapped. I would like that long.
Hi,
Yes that box is in admin/productsmap.php, to make it full width look for the following code at line 56:
widget_textBox("Name","name",TRUE,(isset($_POST["name"])?$_POST["name"]:""),"",3);
...and REPLACE with:
widget_textBox("Name","name",TRUE,(isset($_POST["name"])?$_POST["name"]:""),"",12);
Cheers,
David.
--
PriceTapestry.com
Hi Tobix,
My apologies I have been having some issues with the forum database, if you are still having problems with the discount percentage modification for Featured Products / Search Results let me know and I'll check that out further with you; specifically if after making the changes there were no errors; just no savings being shown where they should be?
Cheers,
David.
--
PriceTapestry.com
Hi Davide,
On the products page I see everything fine.
I don't see anything instead, as if I hadn't put the code in either the searchresults.php or futured.php.
:(
Hi Tobix,
Let's get it working for Featured Products first. So just to confirm the modifications in index.php you have added the AVG(price) AS avgPrice at line 33 so you have;
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, AVG( price ) AS avgPrice, COUNT( id ) AS numMerchants, ".$sqlCase." FROM `".$config_databaseTablePrefix."products` WHERE normalised_name IN (".$sqlIn.") GROUP BY normalised_name ORDER BY sequence";
And then at the top of html/featured.php you have added:
<?php
foreach($featured["products"] as $k=> $product)
{
$featured["products"][$k]["saving"] = round((($product["avgPrice"] - $featured["products"][0]["price"])/$product["avgPrice"])*100,2);
}
?>
With the above in place; please can you post the additional code you have added to html/featured.php to actually output $product["saving"] within the loop and I'll check that out for you...
Cheers,
David.
--
PriceTapestry.com
Hi David,
i copy this is Code:
<span class="radius secondary label"><?php if ($saving): ?>
RISPARMI <bold><?php print $saving; ?>%</bold>
<?php endif; ?></span>
Hi Tobix,
The code needs to use $product["saving"] rather than $saving in this case; have a go with:
<span class="radius secondary label"><?php if ($product["saving"]): ?>
RISPARMI <bold><?php print $product["saving"]; ?>%</bold>
<?php endif; ?></span>
Cheers,
David.
--
PriceTapestry.com
We are almost there. The problem is that the percentage is wrong very often gives me an example -211% o -240.06% :(
Hi Tobix,
Ah, the code to calculate the saving was using the price from the first Featured Product for all products, it should be using the minPrice value from the current product. The correct code for the top of html/featured.php:
<?php
foreach($featured["products"] as $k=> $product)
{
$featured["products"][$k]["saving"] = round((($product["avgPrice"] - $product["minPrice"])/$product["avgPrice"])*100,2);
}
?>
Let me know once that's all OK and then will details the same for search results...
Cheers,
David.
--
PriceTapestry.com
Work now!
But do you think you can also use it for searchresults.php?
Hi Tobix,
For Search Results (and Related Products), first make a Search and Replace as follows:
Search:
MIN(price) as minPrice
Replace:
MIN(price) as minPrice,AVG( price ) as avgPrice
in
search.php (7 instances)
And (unfortunately case slightly different!)
Search:
MIN(price) AS minPrice
Replace:
MIN(price) AS minPrice,AVG( price ) AS avgPrice
in
products.php (1 instance)
Then add the following PHP section to the top of html/searchresults.php:
<?php
foreach($searchresults["products"] as $k=> $product)
{
$searchresults["products"][$k]["saving"] = round((($product["avgPrice"] - $searchresults["products"][0]["price"])/$product["avgPrice"])*100,2);
}
?>
And in the loop foreach product, same code as for Featured Products:
<span class="radius secondary label"><?php if ($product["saving"]): ?>
RISPARMI <bold><?php print $product["saving"]; ?>%</bold>
<?php endif; ?></span>
Cheers,
David.
--
PriceTapestry.com
Hi, David,
unfortunately it gave me the error like -250% etc etc.
I changed the searchresults.php code in the following way and now everything works ... it can be useful to other users:
<?php
foreach$searchresults["products"] as $k => $product)
{
$searchresults["products"][$k]["saving"] = round((($product["avgPrice"] - $product["minPrice"])) / $product["avgPrice"]) * 100,2);
}
?>
Ah sorry about that!
I'd copied the wrong section of code from above when re-working for Search Results...
Cheers,
David.
--
PriceTapestry.com
Hi Tobix,
I'm not sure I understand sorry - the product name (on pt_products) and a mapped product name (as entered in Product Mapping) is limited to 255 characters do you need to make that longer so you can use longer names?
Cheers,
David.
--
PriceTapestry.com