HI David
As you know we have a heavily modified verion of PT and display our discounts codes, offers etc on a seperate page, as opposed to within the price comparison results.
Not sure if you can help as it is already modified code
We have an issue with the dates, added a code today and set expiry date of 30 April 2012, however it is showing on the site as Valid from: 09/09/2011 Expires: 28/11/2012
Any ideas?
Regards
Stuart
Hi David
I believe this is the code you need to see. Thanks, Stuart
$sql = "SELECT * FROM `".$config_databaseTablePrefix."vouchers` WHERE ( (valid_from < '".$now."' AND valid_to = '0') OR (valid_from <= '".$now."' AND valid_to > '".$now."' AND code <> 'NONE' AND code <> 'SALE' AND code <> 'PRINTABLE') ) ORDER BY merchant";
if (database_querySelect($sql,$vouchers))
{
foreach($vouchers as $k => $voucher)
{
if (file_exists("logos/".$voucher["merchant"]))
{
$vouchers[$k]["logo"] = "logos/".$voucher["merchant"];
}
$vouchers[$k]["href"] = $voucher["merchant_link"];
$count ++;
$vouchers[$k]["text"] = $voucher["discount_text"];
$vouchers[$k]["text"] .= " <span style='colour:blue;cursor:pointer;' onclick='document.getElementById(\"vc".$count."\").style.display = \"inline\";window.open(\"".$voucher["merchant_link"]."\");'><br /><img style='vertical-align:middle;float:left;' src='images/reveal-code-visit-site.gif' alt='' /></span>";
$valid_from = @date("d/m/Y",$voucher["valid_from"]);
$valid_to = @date("d/m/Y",$voucher["valid_to"]);
$dates = '<span style="font-size:10px;color:#a1a1a1;">Valid from: '.$valid_from.' Expires: '.$valid_to.'</span>';
$vouchers[$k]["text"] .= " <span id=\"vc".$count."\" style='display:none;'><span class='voucher_code'>".$voucher["code"]."</span> <div style='font-size:12px;float:right;width:370px;padding-top:10px;'><strong>Using your code:</strong> The ".$voucher['merchant']." website has been opened in a new window. Simply copy and paste the code and enter it at the checkout</div></span>";
}
$coupon_type = 'Voucher Code';
$coupons["vouchers"] = $vouchers;
}
Hi Stuart,
Everything looks fine as far as I can tell; I just double checked the strtotime/date logic. After you save and edit the voucher code if you then go back to edit it has the date changed at that point?
Cheers,
David.
--
PriceTapestry.com
I have just tried editing the top voucher on this page
{link saved}
The date in the admin area is correct but what is displaying is incorrect, even after editing
regards
Stuart
Hi Stuart,
I noticed from your page that actually all vouchers were showing the same from / to dates which I think is just the last $dates that was created. What I think you need to do is instead of this line from the code posted above:
$dates = '<span style="font-size:10px;color:#a1a1a1;">Valid from: '.$valid_from.' Expires: '.$valid_to.'</span>';
use:
$vouchers[$k]["dates"] = '<span style="font-size:10px;color:#a1a1a1;">Valid from: '.$valid_from.' Expires: '.$valid_to.'</span>';
And then in your html/coupons.php I think you will have:
$dates
...which can then be replaced with:
$voucher["dates"]
Cheers,
David.
--
PriceTapestry.com
Hi Stuart,
If you'd like to post the section of code generating the Valid from: ... Expires: ... output I'll take a look for you...
Cheers,
David.
--
PriceTapestry.com