Jump to content

Recommended Posts

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.

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!

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;
?>

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.

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.