Hi David,
you remember the coding for a product of the day additionally to the featured products. Now I want the featured products showing only products with the smallest price and if possible this only for a time span from 1-10th of a month.
The reason behind is that my customers do not buy between the 1-10th of a month and I want them to buy so the smallest price should be a bait.
Regards
roland
Hi David,
I was out for some days.
The sql should not be changed but only the mod of product of the day.
Regards
Roland
Hello Roland,
Can you post the code from your index.php that does the product of the day so that I know what code you currently have in order to make the modification. If you're not sure which section of code it is feel free to email me the file and i'll make the changes for you. I will make it configurable so you can pick the maximum price and the number of days in the month to only use products up to that price...
Cheers,
David.
Hi Roland,
I got your email. In the "Product of the day" section, where you currently have:
$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` ORDER BY RAND(".$seed.") LIMIT 8";
...change this as follows:
$maxPrice = 20.00; // change this for the maximum price displayed at start of month
if (date("j") <= 10) // change this for more or less days
{
$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` ORDER BY RAND(".$seed.") LIMIT 8";
}
else
{
$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE price < '".$maxPrice."' ORDER BY RAND(".$seed.") LIMIT 8";
}
Hope this helps,
Cheers,
David.
Hi David,
thanks for the code but it does not work as wanted. Ohter prices than the maxPrice appear when the page is loaded.
Regards
Roland
Hello Roland,
Oops - the cases are the wrong way round - try this:
$maxPrice = 20.00; // change this for the maximum price displayed at start of month
if (date("j") <= 10) // change this for more or less days
{
$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE price < '".$maxPrice."' ORDER BY RAND(".$seed.") LIMIT 8";
}
else
{
$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` ORDER BY RAND(".$seed.") LIMIT 8";
}
Cheers,
David.
Hi David , i ve posted here as i cant find the code for the product of the day script.
i just want one random product displayed and for it for cahnge once a day or once a week.
reading this thread it looks like u have ansered it before but i cant find the thread.
cheers
Hi Jonny,
It uses the Featured Products code; and simply replaces the first line of the featured products section (from index.php):
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
with:
$seed = strtotime(date("Y-m-d"));
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND(".$seed.") LIMIT 1";
If you want the product of the day in addition to the regular Featured Products; simply copy the entire section of Featured Products code from index.php, from the line above, down to and including:
if (isset($featured)) require("html/featured.php");
...and use the entire block wherever you want product of the day displayed. This works by setting the seed of MySQL's rand() function to a number which is based on today's date - so you will get the same result every time the query is used on the same day.
Cheers,
David.
Hi Roland,
It should be straight forward to change the SQL used based on the day of the month (if date("j") index.php to show random featured products instead of the products taken from the featured products table as edited in your admin area? Alternatively, the same mod can be applied to your product of the day if this is what you were wanting to do...
Cheers,
David.