hi David
i have a problem, one of the api's we are integrating has to be set up to do a request for a whole city, they have no way of integrating the api on a single item basis so what we need to do is to add extra items/ table to search loop, to get the api working i had to create 3 new tables with the data for the room, country, and city codes so we can do the main request i have all that data, i wanted to populate a new table pt_rooms which we will use for live availability but after the items are into that table i need to make it so they appear on the search page,
i was wondering i know there is some features in the price field to link products that are the same i was wondering would it be possible to use the built in script to display the product data according to title product underneath the actual product that it matches on the search listing like the items i have set up already
if you visit {link saved} you will see some that i have already set up, so i basically want to be able to link the titles in my extra database with the products we allready have and then give out the tables info under the corresponding product
King Regard,
Michael
hi David thanks, that helped me out a lot now i can save the extra data to mySQL and use it that way
thanks again
King Regards,
Michael
hi David
so i finally managed to get the extra data into the table with xpath and implemented the code above like so:
$sql ="";
$customHTML = "";
$sql = "SELECT * FROM `pt_rooms` WHERE name='".$wpdb->escape($row->name)."'";
$items = $wpdb->get_results($sql, ARRAY_A);
if ($wpdb->query($sql))
{
$customHTML = "";
foreach($items as $item){
$tbrt = $item['room_type'];
$tbdesc = $item['description'];
$tbaval = $item['avail'];
$tbprice = $item['price'];
$tbcur = $item['currency'];
$customHTML .= "<tr><td>'".$tbrt."'</td><td>'".$tbdesc."'</td><td>'".$tbaval."'</td><td>'".$tbprice.$tbcur."'";
}
} else {
$customHTML = "<tr><td></td><td>sorry no data</td></tr>";
}
$each = str_replace("%CUSTOM%",$customHTML,$each);
but to add to this is there a way to add the price in the extra database to the calculations for the price that is allready set up so it shows the cheapest price for the extra database aswell as or instead of the current prices?
Best Regards,
Michael
Hello Michael,
There are a couple of caveats but if a) sort is _not_ priceAsc or priceDesc and b) numMerchants is 1 then you could simply use your $item['price'] value as the replacement for %PRICE%. Firstly, make sure that your code above is at the top of the foreach() loop for each $row, then look for the following code at line 490:
$each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);
...and REPLACE with:
global $pto_sort;
if( ($pto_sort <> "priceAsc") && ($pto_sort <> "priceDesc") && ($row->numMerchants==1) )
{
$row->minPrice = $item['price'];
}
$each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);
Cheers,
David.
--
PriceTapestry.com
Hello Michael,
Sure - the loop to generate plugin search results is in pto_search.php within the function pto_search_html() which beings at line 423.
It is safe to make additional database queries at this point in the code as the results are generated from the $pto_searchResults global rather than a live $wpdb object.
The product name for each result is displayed indirectly by the following code at line 449.
$each = str_replace("%PRODUCT_NAME%",$row->name,$each);
...which replaces %PRODUCT_NAME% in your Search Results / Each template (wp-admin > Settings > PriceTapestry.org). To include your custom table information after this point; I would add support for a new placeholder, %CUSTOM%, so the first step would be to add %CUSTOM% to your Search Results / Each template at the position required. Then, to replace out with your custom display, work around something like this, inserted immediately after the line identified above:
$customHTML = "";
$sql = "SELECT * FROM custom_table_1 WHERE name='".$wpdb->escape($row->name)."'";
if ($wpdb->query($sql))
{
// construct $customHTML content from $wpdb->last_result[0] e.g.
$customHTML = <br />Example Field 1: ".$wpdb->last_result[0]["example_field_1"];
$customHTML = <br />Example Field 2: ".$wpdb->last_result[0]["example_field_2"];
}
$sql = "SELECT * FROM custom_table_2 WHERE name='".$wpdb->escape($row->name)."'";
if ($wpdb->query($sql))
{
// construct $customHTML content from $wpdb->last_result[0] e.g.
$customHTML = <br />Example Field 3: ".$wpdb->last_result[0]["example_field_3"];
$customHTML = <br />Example Field 4: ".$wpdb->last_result[0]["example_field_4"];
}
$each = str_replace("%CUSTOM%",$customHTML,$each);
Hope this points you in the right direction!
Cheers,
David.
--
PriceTapestry.com