How can I add the best price for a product into its description? (for my purposes this would be the maxprice).
To be really complex I would like to add the maxPrice only from merchants that have a specific word in the description ie:
for
http://rewardsdb.com/product/Dell.html
The description output would ideally be "3% Cashback"
Is there any way to do this?
Andrew
Thanks - I think I didn't explain very well. I was talking about the meta tag description rather than the description field in the DB.
I'd like to show the highest cashback in the meta description (this may not however be the highest value in the price field due to points and miles programs) - so it needs to display the highest 'price' amongst merchants with "CASHBACK" in the merchant name. Ideally it would be merchants with CASHBACK in their name but not FLAT RATE.
Does that make more sense?
Hi Andrew,
The meta tag description is set by the following code in products.php
$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
Similar modifications to those described above can be made here; the best price is in exactly the same variable.
To modify this to search for "CASHBACK" in the merchant name and then apply the extra description, try this code in place of the above:
$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
if (strpos($q,"CASHBACK")!==FALSE)
{
// append the best price
$header["meta"]["description"] .= " ".$prices["products"][0]["price"];
}
Hope this helps!
Cheers,
David.
David,
Sorry - it doesn't work. I think a big part of the issue is the way I use Pricetapestry. Since it is used for rewards comparison the HIGHEST 'price' is the best (most reward) rather than the usual lowest. I also mix a number of rewards types (cashback, miles, points) together in the database.
Please look at http://rewardsdb.com/product/Kmart.html
For RewardsDB;
Product = the store searched for (ie Kmart)
Merchant = rewards program (ie Quizpoints CASHBACK USA)
Description = store URL (ie kmart.com)*
As you can see the best (ie Highest) Cashback rate listed is 2% (while the Best Miles are 3, and Best Points are 24) - there is also a support link which is has a 0 value which is the one that provides the product image etc on top of the page.
I would like to change the $header["title"] (i'll change the description along the same basis) to (in this example);
Kmart (kmart.com) 2% Cashback + Coupon Codes Coupons Rebates Discounts Rewards Points & Miles @ RewardsDB.com
where Kmart is .htmlentities($q,ENT_QUOTES,$config_charset).
where kmart.com is .htmlentities($product["products"][0]["description"],ENT_QUOTES,$config_charset).
the % Cashback should only show from the highest value merchant with CASHBACK (but not FLAT RATE) in the merchant name
If there is no % Cashback then the Title should be;
Kmart (kmart.com) Coupon Codes Coupons Cashback Rebates Discounts Rewards Points & Miles @ RewardsDB.com
*Note that the database field 'description' contains the product display URL - in this case kmart.com - the visable description on the right of the product image is provided via a php include.
Hi,
You can access the opposite entry in the array, by instead of:
$prices["products"][0]["price"]
...using:
$prices["products"][(count($prices["products"])-1)]["price"]
Cheers,
David.
Hi Andrew,
Within html/product.php, the best price will be in the variable:
$prices["products"][0]["price"]
The description is displayed by the following code (line 13 in the distribution):
<p><?php print $mainProduct["description"]; ?></p>
...so to append the best price, try this:
<p><?php print $mainProduct["description"]." ".$prices["products"][0]["price"]; ?></p>
It's not much more code to search for a keyword in the description and only display the best price if that specific word is present. Try this:
<p>
<?php
print $mainProduct["description"];
if (strpos($mainProduct["description"],"keyword")!==FALSE)
{
print $prices["products"][0]["price"];
}
?>
</p>
Hope this helps!
Cheers,
David.