Hello David
Would it be possible to following to the description header tags, say Avaiable between "This PRODUCTNAME is available from ****(lowest Price)**** and *****(Hightest Price)******"
Thanks
Mally
magazine subscriptions
Hello David
I've started seeing results in the search engines reflecting the description tag however for example Nursing Times Magazine is appearing as
Subscribe to Nursing Times Magazine is available from £64 to £67.5 at MagazineSubscription.co.uk
Is there away of changing the £67.5 to decimal format £67.50 ??
thanks
Mally
Hi Mally,
Yes - the fields can be output using sprintf() to use 2 decimal places. Here's an alternative version to fix this:
$min = floatval($product["products"][0]["price"]);
$max = floatval($product["products"][count($product["products"])-1]["price"]);
if ($min < $max)
{
$description = "This ".htmlentities($q,ENT_QUOTES,$config_charset)." is available from ".$config_currencyHTML.sprintf("%.2f".$min)." to ".$config_currencyHTML.sprintf("%.2f",$max);
}
else
{
$description = "This ".htmlentities($q,ENT_QUOTES,$config_charset)." is available for ".$config_currencyHTML.sprintf("%.2f",$min);
}
$header["meta"]["description"] = $description;
That should help!
Cheers,
David.
Hi David
Copied the above code but got the following error when I looked at a product
Warning: sprintf() [function.sprintf]: Too few arguments in /home/magsub/public_html/products.php on line 57
Warning: sprintf() [function.sprintf]: Too few arguments in /home/magsub/public_html/products.php on line 57
Warning: Cannot modify header information - headers already sent by (output started at /home/magsub/public_html/products.php:57) in /home/magsub/public_html/html/header.php on line 12
Mally
Hello Mally,
My apologies - i'd mistyped "," as "." within the sprintf calls. I've fixed this in the code above...!
Cheers,
David.
Thanks David, now sorted, great stuff. Thanks
Mally
Hi Mally,
The meta description tag is set by the following code in products.php
$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
At this point, the prices are in the array $product["products"], ordered by price, so the cheapest is:
$product["products"][0]["price"]
...and the most expensive:
$product["products"][count($product["products"])-1]["price"]
Therefore, have a go with this code in place of the above to create the text you want:
$min = floatval($product["products"][0]["price"]);
$max = floatval($product["products"][count($product["products"])-1]["price"]);
if ($min < $max)
{
$description = "This ".htmlentities($q,ENT_QUOTES,$config_charset)." is available from ".$config_currencyHTML.$min." to ".$config_currencyHTML.$max;
}
else
{
$description = "This ".htmlentities($q,ENT_QUOTES,$config_charset)." is available for ".$config_currencyHTML.$min;
}
$header["meta"]["description"] = $description;
Hope this helps!
Cheers,
David.