didz666 Posted December 20, 2015 Share Posted December 20, 2015 Hi very new to php and all things web so please bare with me. I'm using an api call that display related items for a given product it receives from a query in the url. I would like to add another variable to the url so when i input the current product "ID" that item is not shown in the related items carousel but if no item id is found display all as normal. If that makes sense. Any help would be really appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/ Share on other sites More sharing options...
ginerjm Posted December 21, 2015 Share Posted December 21, 2015 No it doesn't. Does the API that you call (1) actually generate this display, or do you (2)do the displaying. If 1 - the api has to be aware of your "new" query item in order to affect the behavior. If 2 - Of course you can! Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/#findComment-1528330 Share on other sites More sharing options...
didz666 Posted December 21, 2015 Author Share Posted December 21, 2015 Hi ginerjim thanks for your reply. I have attached the api call below. (eBay Finding api) The api does the searching and then display its findings into a jquery carousel. I know i need to add a $_REQUEST with the variable itemID or similar, its what to next im unsure about. I hope this makes better sense. I just don't want the item i'm currently viewing to be included in the similar items carousel. thanks again for your time. <?php error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging // API request variables $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; $version = '1.12.0'; $appid = ''; // Replace with your own AppID $globalid = 'EBAY-GB'; $query = ''; $safequery = urlencode($query); // Construct the findItemsByKeywords HTTP GET call $apicall = "$endpoint?"; $apicall .= "OPERATION-NAME=findItemsIneBayStores"; $apicall .= "&SERVICE-VERSION=$version"; $apicall .= "&SECURITY-APPNAME=$appid"; $apicall .= "&GLOBAL-ID=$globalid"; $apicall .= "&keywords=$safequery" $apicall .= "&paginationInput.entriesPerPage=18"; $apicall .= "&keywords="; // Load the call and capture the document returned by eBay API $resp = simplexml_load_file($apicall); // Check to see if the request was successful, else print an error if ($resp->ack == "Success" ) { $results = ''; // If the response was loaded, parse it and build links foreach($resp->searchResult->item as $item) { if ($item->pictureURLLarge) { $pic = $item->pictureURLLarge; } else { $picsml = $item->galleryURL; } $pic = $item->pictureURLLarge; $picsml = $item->galleryURL; $link = $item->viewItemURL; $title = $item->title; $price = $item->sellingStatus->convertedCurrentPrice; // For each SearchResultItem node, build a link and append it to $results $results .= "<div class='output'></div>" // include all elements you want to display echo $results; ?> Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/#findComment-1528384 Share on other sites More sharing options...
ginerjm Posted December 21, 2015 Share Posted December 21, 2015 1 - see my signature for the proper use of error reporting. 2 - looking at the explanation you gave it would seem that YOU are doing the display using data passed back . I don't know what a "jquery carousel" is but if the data comes back to you then you determine what you output. Simple as that. Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/#findComment-1528387 Share on other sites More sharing options...
didz666 Posted December 21, 2015 Author Share Posted December 21, 2015 Hi im not explaining it right. The results returned by the call are governed by the search term "query" in my case and i then choose what to include in the output as you mentioned. There are no options within the call itself to not display an item so its all or nothing. This is my issue i want to be able to single out a product using its itemID and stop it from being displayed if its the same as the item being viewed at that time. being a total novice i have no idea where to start i may be wanting something that cant be done. Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/#findComment-1528394 Share on other sites More sharing options...
ginerjm Posted December 21, 2015 Share Posted December 21, 2015 And THAT is exactly what I said from the start. And in my last post. The data returned is your responsibility to output, no? So - you decide what to output. Don't forget to add the missing line in your error reporting code from my signature Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/#findComment-1528395 Share on other sites More sharing options...
didz666 Posted December 21, 2015 Author Share Posted December 21, 2015 Hi i have added ini_set('display_errors', '1'); to the code thanks for that, i will go do some more research thanks for your time. Quote Link to comment https://forums.phpfreaks.com/topic/299903-hide-current-item-from-related-items-api-results/#findComment-1528400 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.