Results 1 to 6 of 6
  1. #1
    Newbie
    Join Date
    July 6th, 2009
    Posts
    2
    Question Example of store using Data Pack features?
    Hi, Do you have an example of a store where I can see all the Data Pack features in action? We know for sure we'll use PopShops to build several affiliate stores but need to determine which plan works best for us. We don't have a developer but are willing to hire one if we can see on a sample site that the Data Pack's extra features are something we should take advantage of.

    Thanks

    Alessandra

  2. #2
    Full Member JessieJ's Avatar
    Join Date
    July 13th, 2006
    Location
    Seattle, WA
    Posts
    426
    Hi,
    The store megabuzz.com was built using data pack but there are a bunch of other ways to use it. We're going to be collecting scripts to let devs play around with it on this page:

    http://popshops.com/affiliate-code

    You can see the store and the code it was built from. Hope that helps.
    Jessie Jones
    Create your custom affiliate store with PopShops.
    General support: support [at] popshops.com | Merchant requests: merchants [at] popshops.com
    (Include your popshops login, your shop name, and the URL or merchant you have an issue with.)

  3. #3
    Newbie
    Join Date
    July 6th, 2009
    Posts
    2
    Building a popshops dynamic categorized store on Wordpress
    Thanks a lot for your prompt response, Jessie! After visiting the link you sent me we have decided to downgrade to the Enterprise Plan to begin with as we won't be needing the Data Feed features immediately.

    What we need to do is create a dynamic categorized store on Wordpress, this is the way i thought of doing it:

    Pick a few products from different merchants to go on my store's homepage. Pull this store through the wordpress plugin into a wordpress page.

    Create a php code like the one Dan created for his superheroes store and embed it right before my store (by means of a wordpress plugin that embeds php).

    Create and upload the category.php file.

    Is this the right/easiest way to go about creating a DYNAMIC CATEGORIZED store on wordpress?

    Thank you!

    Alessandra

  4. #4
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by JessieJ
    Hi,
    The store megabuzz.com was built using data pack but there are a bunch of other ways to use it. We're going to be collecting scripts to let devs play around with it on this page:

    http://popshops.com/affiliate-code

    You can see the store and the code it was built from. Hope that helps.
    Hey there Jessie,

    I took a look at that code and something struck me that I just had to bring up. I saw several instances of <? instead of <?php and I know that is a problem on some web hosts. So if anybody has any issues with the code a possible solution would be to switch all the <? to <?php.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  5. #5
    ABW Ambassador meadowmufn's Avatar
    Join Date
    January 18th, 2005
    Location
    Seattle
    Posts
    2,587
    Another thing I noticed is that both examples have a call to require("popshops.php"). Where is the code to that file and/or what's supposed to be in it?
    -Don't criticize anyone til you've walked a mile in their shoes. Then when you do criticize them, you'll be a mile away and have their shoes.
    - Silence is golden. Duct Tape is silver.

  6. #6
    Full Member JessieJ's Avatar
    Join Date
    July 13th, 2006
    Location
    Seattle, WA
    Posts
    426
    PopShops class
    Hi,
    I will need to wait for a confirmation from the dev who built those, BUT I think those refer to the "popshops class" which, in essence, tell the PHP how to interact with the PopShops API. Any script would need some variation of a class to work.

    Here are the contents of popshops.php. I will also post on the scripts page:

    Code:
    <?php
    defined('POPSHOPS_API_VERSION') or die('');
    
    class PopShops {
        
      function PopShops($options=array()) {
        // Setup required api keys
        $this->apiKey = $options['api_key'];
        $this->catalogKey = $options['catalog_key'];
        $this->apiVersion = POPSHOPS_API_VERSION;
        
        // Setup list of categories to build predefined searches to be used as categories
        $this->categories = (isset( $options['categories'] ) ) ? $options['categories'] : array();
        
        // Setup default parameters for how many results to return
        $this->subid = (isset( $options['subid'] ) ) ? $options['subid'] : 'popshops';    
        $this->localRedirects = (isset( $options['localRedirects'] ) ) ? $options['localRedirects'] : false;
        $this->productLimit = (isset( $options['productLimit'] ) ) ? $options['productLimit'] : 9;
        $this->productGridColumns = (isset( $options['productGridColumns'] ) ) ? $options['productGridColumns'] : 3;
        $this->productOffset = 0;
        $this->dealLimit = (isset( $options['dealLimit'] ) ) ? $options['dealLimit'] : 25;
        $this->dealOffset = 0; 
        $this->nameSpace = (isset( $options['nameSpace'] ) ) ? $options['nameSpace'] : 'psps_';
        
        if ( !isset( $_REQUEST[ $this->nameSpace.'keywords' ] ) && isset( $options['defaultSearch'] ) ) {        
          $_REQUEST[ $this->nameSpace.'keywords' ] = $options['defaultSearch']; 
        }
            
        // Setup list of parameters to pass on to PopShops. These will be parsed out of the url.
        $this->params = array('keywords','merchant_id','merchant_type_id','category_id','brand_id','price_min','price_max','product_sort','product_limit','product_offset','product_group_id','deal_type_id','deal_offset');
      }
      
      function findMerchants() {
        $request = "http://www.popshops.com/v".$this->apiVersion."/".$this->apiKey."/merchants.xml?";
        $request .= "catalog_key=".$this->catalogKey;
        $this->merchantResults = $this->requestResults($request);
      }
      
      function findDeals() {
        $request = "http://www.popshops.com/v".$this->apiVersion."/".$this->apiKey."/deals.xml?";
        $request .= "catalog_key=".$this->catalogKey;
        $request = $this->addParameter($request, 'deal_limit', $this->dealLimit);  	
        $request = $this->addParameters($request,$this->params);
        $this->dealResults = $this->requestResults($request);    
      }
      
      function findDealTypes() {
        $request = "http://www.popshops.com/v".$this->apiVersion."/".$this->apiKey."/deal_types.xml";
        $this->dealTypeResults = $this->requestResults($request);
      }
      
      function findMerchantTypes() {
        $request = "http://www.popshops.com/v".$this->apiVersion."/".$this->apiKey."/merchant_types.xml";
        $this->merchantTypeResults = $this->requestResults($request);
      }
      
      function findNetworks() {
        $request = "http://www.popshops.com/v".$this->apiVersion."/".$this->apiKey."/networks.xml";
        $this->networkResults = $this->requestResults($request);
      }
      
      function findProducts(){
      	$request = "http://www.popshops.com/v".$this->apiVersion."/".$this->apiKey."/products.xml?";
      	$request .= "catalog_key=".$this->catalogKey;
      	$request = $this->addParameter($request, 'product_limit', $this->productLimit);  	
      	$request = $this->addParameters($request,$this->params);  	
      	$this->productResults = $this->requestResults($request);
      }
      
      function productStoreName($product){
        $out = '';
        $storeName = $this->merchantNameFor($product);
        
        if (!empty($storeName)) {
          $out .= '<p class="psps-text psps-store-name"><span>Store: </span>';
          $out .= '<a href="'.$this->localRedirectURL($product['url']) .'" rel="nofollow">'.$storeName.'</a>';
          $out .= '</p>';
        }
        return $out;
      }
      
      function productPrice($product){
        $out = '';
        $out .= '<p class="psps-text psps-price">';
        
        if (intval($product['merchant_price']) > 0 && (floatval($product['merchant_price']) != floatval($product['retail_price']))) {
          $out .= '<span class="psps-retail-price"><del>$'.number_format($product['retail_price'],2).'</del></span>';
          $out .= '<span class="psps-store-price">$'.number_format($product['merchant_price'],2).'</span>';      
        } else {
          $out .= '<span class="psps-store-price">$'.number_format($product['merchant_price'],2).'</span>';
        }
        
        $out .= '</p>';
        return $out;
      }
      
      function renderProduct($product) {
        $out = '';
        $out .= '<div class="psps-img"><a href="'.$this->localRedirectURL($product['url']).'" rel="nofollow"><img src="'.$product['large_image_url'].'" /></a></div>';
        $out .= $this->productPrice($product);
        $out .= '<p class="psps-text psps-name"><a href="'.$this->localRedirectURL($product['url']).'" rel="nofollow">'.$product['name'].'</a></p>';
        $out .= '<p class="psps-text psps-description">'.substr($product['description'],0,150) .'...</p>';
        $out .= $this->productStoreName($product);
        return $out;
      }
      
      function renderProductGrid() {
        $out = '<table style="float:left;">';
     
        $count = 0;
        $rowCount = 1;
        $cols = $this->productGridColumns;
        $size = sizeof($this->productResults->products->product);
    
        foreach($this->productResults->products->product as $product) {
          if ($count%$cols == 0) { $rowCount++; }
          
          if (($count == 0) || ($count%$cols == 0)) { $out .= '<tr>'; }
          
          $out .= '<td class="psps-cell">';
          $out .= $this->renderProduct($product);
          $out .= '</td>';
    
          // This will add any additional cells in the last row that might be missing. 
          if ( $size == $count+1 && $size%$cols != 0 ) { 
            $i = 0;
            while ( $i < ( $cols - $size%$cols) ) {
              $out .= '<td>&nbsp;</td>';
              $i++; 
            }
          }
          
          $count++;
          if (($count%$cols == 0) || ($count == $size)) { 
            $out .= '</tr>';
          } 
        }
        
        $out .= '</table>';
        return $out;
      }
      
      function renderCustomCategories(){
        $out = '';
        if (sizeOf($this->categories) > 0) {
          $out .= '<h3>Popular categories</h3>';
          $out .= '<ul>';
          foreach ($this->categories as $category) {
            $out .= '<li>'.$this->customCategoryLink($category).'</li>';
          }
          $out .= '</ul>';      
        }
        return $out;
      }
        
      function merchantNameFor($object) {
        if (isset($this->merchantResults)) {
          $merchants = $this->merchantResults;
        } else {
          $merchants = isset($this->productResults) ? $this->productResults->merchants : $this->dealResults->merchants;
        }
        
        foreach($merchants->merchant as $merchant) {
          if (intval($merchant['id']) == intval($object['merchant_id'])) {
            return $merchant['name'];
          }
        }
        return '';
      }
      
      function merchantLogoFor($object) {
        if (isset($this->merchantResults)) {
          $merchants = $this->merchantResults;
        } else {
          $merchants = isset($this->productResults) ? $this->productResults->merchants : $this->dealResults->merchants;
        }
        
        foreach($merchants->merchant as $merchant) {
          if (intval($merchant['id']) == intval($object['merchant_id'])) {
            return $merchant['logo_url'];
          }
        }
        return '';
      }
      
      function localRedirectURL($destination) {
        if ( $this->localRedirects == true ) {
          $url = $this->baseURL($this->params);
          $url = str_replace('?&','?',$url);
          $delimiter = (strpos($url,'?') > -1) ? '&' : '?';
          return $url.$delimiter.$this->nameSpace.'destination='.str_replace('http://','',$destination);
        } else {
          return $destination;
        }    
      }
      
      function renderDealRows(){
        $out = '';
        if (sizeOf($this->dealResults->deals->deal) > 0) {
          $out .= '<ul>';
          foreach($this->dealResults->deals->deal as $deal) {
            $out .= '<li><div class="psps-deal">';
            $out .= '<div class="psps-deal-logo"><a href="'.$this->localRedirectURL($deal['url']).'" rel="nofollow"><img src="'.$this->merchantLogoFor($deal).'" alt="'.$this->merchantNameFor($deal).'"/></a></div>';
            $out .= '<div class="psps-deal-name">'.$deal['name'].'</div>';
            $out .= '<div class="psps-deal-meta">';
            $out .= '<span class="psps-deal-expiration">Expires: '.$deal['end_on'].'</span>';
            if (isset($deal['code'])) {
              $out .= '<span class="psps-deal-code">Code: '.$deal['code'].'</span>';
            }
            
            $out .= '</div>';
            $out .= '</div></li>';
          }
          $out .= '</ul>';
        }
        return $out;
      }
      
      function renderDeals(){
        $out = '';
        if (sizeOf($this->productResults->deals->deal) > 0) {
          $out .= '<h3>Deals</h3>';
          $out .= '<div class="psps-filter-options psps-tall">';
          $out .= '<ul>';
          foreach($this->productResults->deals->deal as $deal) {
            $out .= '<li><div class="psps-deal">';
            $out .= '<div class="psps-merchant"><a href="'.$this->localRedirectURL($deal['url']).'" rel="nofollow">'.$this->merchantNameFor($deal).'</a></div>';
            $out .= '<div class="psps-name">'.$deal['name'].'</div>';
            $out .= '</div></li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }
        return $out;
      }
      
      function renderDealMerchantTypeFilter(){
        return $this->renderMerchantTypeFilter($this->dealResults);
      }
      
      function renderDealMerchantTypeSelect(){
        return $this->renderMerchantTypeSelect($this->dealResults);
      }
      
      function renderDealMerchantFilter(){
        return $this->renderMerchantFilter($this->dealResults);
      }
      
      function renderDealMerchantSelect(){
        return $this->renderMerchantSelect($this->dealResults);
      }
      
      function renderDealTypeFilter(){
        $out = '';
        if (sizeOf($this->dealResults->deal_types) > 0) {
          $out .= '<h3>Types of deals</h3>';
          $out .= '<div class="psps-filter-options">';
          $out .= '<ul>';
          foreach($this->dealResults->deal_types->deal_type as $dealType) {
            $out .= '<li>';
            $out .= '<span class="psps-label">'.$this->dealTypeLink($dealType).'</span>';
            $out .= ' <span class="psps-count">('.number_format($dealType['deal_count']).')</span>';
            $out .= '</li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }
        return $out;
      }
      
      function renderDealTypeSelect(){
        $out = '';
        if (sizeOf($this->dealResults->deal_types) > 0) {
          $out .= '<h3>Types of deals</h3>';
          $out .= '<select class="psps-select" onchange="window.location=this.value;">';
          $out .= '<option value="'.$this->baseURL(array('deal_type_id')).'">All</option>';
          foreach($this->dealResults->deal_types->deal_type as $dealType) {
            $param = isset($_REQUEST[$this->nameSpace.'deal_type_id']) ? $_REQUEST[$this->nameSpace.'deal_type_id'] : 0;
            $selected = (intval($dealType['id']) == intval($param)) ? ' selected="selected"' : '';
            $out .= '<option value="'.$this->dealTypeUrl($dealType).'"'.$selected.'>';
            $out .= $dealType['name'].' ('.number_format($dealType['deal_count']).')';
            $out .= '</option>';
          }
          $out .= '</select>';
        }
        return $out;
      }
      
      function dealTypeLink($dealType) {
        return '<a href="'.$this->dealTypeUrl($dealType).'">'.$dealType['name'].'</a>';    
      }
      
      function dealTypeUrl($dealType) {    
        $url = $this->baseURL(array('deal_type_id'));
        $url = $this->addParameter($url,'deal_type_id',$dealType['id']);
    
        if (isset($_REQUEST[$this->nameSpace.'merchant_type_id'])) {
          $url = $this->addParameter($url,'merchant_type_id',$_REQUEST[$this->nameSpace.'merchant_type_id']);
        }
        
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      
      function renderCategoryFilter(){
        if (isset($_REQUEST[$this->nameSpace.'category_id'])) {
          $this->renderMerchantCategoryFilter();
        } else {
          $this->renderMerchantTypeFilter($this->productResults);
        }
      }
      
      function renderMerchantCategoryFilter(){
        $out = '';
        if (sizeOf($this->productResults->categories->category) > 0) {
          $out .= '<h3>Categories</h3>';
          $out .= '<div class="psps-filter-options">';
          $out .= '<ul>';
          foreach($this->productResults->categories->category as $category) {
            $out .= '<li>';
            $out .= '<span class="psps-label">'.$this->categoryLink($category).'</span>';
            $out .= ' <span class="psps-count">('.number_format($category['product_count']).')</span>';
            $out .= '</li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }
        return $out;
      }
      
      function renderMerchantTypeFilter($results){
        $out = '';
        if (sizeOf($results->merchant_types->merchant_type) > 0) {
          $out .= '<h3>Categories</h3>';
          $out .= '<div class="psps-filter-options">';
          $out .= '<ul>';
          foreach($results->merchant_types->merchant_type as $merchant_type) {
            $out .= '<li>';
            $out .= '<span class="psps-label">'.$this->merchantTypeLink($merchant_type).'</span>';
            $count = isset($merchant_type['deal_count']) ? $merchant_type['deal_count'] : $merchant_type['product_count'];
            $out .= ' <span class="psps-count">('.number_format($count).')</span>';
            $out .= '</li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }
        return $out;
      }
      
      function renderMerchantTypeSelect($results){
        $out = '';
        if (sizeOf($results->merchant_types->merchant_type) > 0) {
          $out .= '<h3>Categories</h3>';
          $out .= '<select class="psps-select" onchange="window.location=this.value;">';
          $out .= '<option value="'.$this->baseURL(array('merchant_type_id')).'">All</option>';
          foreach($results->merchant_types->merchant_type as $merchant_type) {
            $param = isset($_REQUEST[$this->nameSpace.'merchant_type_id']) ? $_REQUEST[$this->nameSpace.'merchant_type_id'] : 0;
            $selected = (intval($merchant_type['id']) == intval($param)) ? ' selected="selected"' : '';
            
            $out .= '<option value="'.$this->merchantTypeUrl($merchant_type).'"'.$selected.'>';
            $out .= $merchant_type['name'];
            $count = isset($merchant_type['deal_count']) ? $merchant_type['deal_count'] : $merchant_type['product_count'];
            $out .= ' ('.number_format($count).')';
            $out .= '</option>';
          }
          $out .= '</select>';
        }
        return $out;
      }
      
      function renderBrandFilter(){
        $out = '';
        if (sizeOf($this->productResults->brands->brand) > 0) {
          $out .= '<h3>Brands</h3>';
          $out .= '<div class="psps-filter-options">';
          $out .= '<ul>';
          foreach($this->productResults->brands->brand as $brand) {
            $out .= '<li>';
            $out .= '<span class="psps-label">'.$this->brandLink($brand).'</span>';
            $out .= ' <span class="psps-count">('.number_format($brand['product_count']).')</span>';
            $out .= '</li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }
        return $out;
      }
      
      function renderMerchantFilter($results){
        $out = '';
        if (sizeOf($results->merchants->merchant) > 0) {
          $out .= '<h3>Stores</h3>';
          $out .= '<div class="psps-filter-options">';
          $out .= '<ul>';
          foreach($results->merchants->merchant as $merchant) {
            $out .= '<li>';
            $out .= '<span class="psps-label">'.$this->merchantLink($merchant).'</span>';
            $count = isset($merchant['deal_count']) ? $merchant['deal_count'] : $merchant['product_count'];
            $out .= ' <span class="psps-count">('.number_format($count).')</span>';
            $out .= '</li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }
        return $out;
      }
      
      function renderMerchantSelect($results){
        $out = '';
        if (sizeOf($results->merchants->merchant) > 0) {
          $out .= '<h3>Stores</h3>';
          $out .= '<select class="psps-select" onchange="window.location=this.value">';
          $out .= '<option value="'.$this->baseURL(array('merchant_id')).'">All</option>';
          foreach($results->merchants->merchant as $merchant) {
            $param = isset($_REQUEST[$this->nameSpace.'merchant_id']) ? $_REQUEST[$this->nameSpace.'merchant_id'] : 0;
            $selected = (intval($merchant['id']) == intval($param)) ? ' selected="selected"' : '';
            
            $out .= '<option value="'.$this->merchantUrl($merchant).'"'.$selected.'>';
            $out .= $merchant['name'];
            $count = isset($merchant['deal_count']) ? $merchant['deal_count'] : $merchant['product_count'];
            $out .= ' ('.number_format($count).')';
            $out .= '</option>';
          }
          $out .= '</select>';
        }
        return $out;
      }
      
      function renderPriceRangeFilter() {
        $out = '';
        if (sizeOf($this->productResults->price_ranges->price_range) > 0) {
          $out .= '<h3>Prices</h3>';
          $out .= '<div class="psps-filter-options">';
          $out .= '<ul>';
          foreach($this->productResults->price_ranges->price_range as $price_range) {
            $out .= '<li>';
            $out .= '<span class="psps-label">'.$this->priceLink(array('price_min' => $price_range['min'], 'price_max' => $price_range['max'])).'</span>';
            $out .= ' <span class="psps-count">('.number_format($price_range['product_count']).')</span>';
            $out .= '</li>';
          }
          $out .= '</ul>';
          $out .= '</div>';
        }    
        return $out;
      }
      
      function renderSuggestedMerchants() {
        if (!isset($this->cachedSuggestedMerchants)) {
          $out = '';
          if (!isset($this->productResults->suggested_merchants)) return $out;
          $out .= '<div id="psps-suggested-merchants">';
          $out .= '<h2>Go directly to this store:</h2>';
          foreach($this->productResults->suggested_merchants->merchant as $suggested_merchant) {
            $out .= '<div class="psps-suggested-merchant">';
            if (strlen($suggested_merchant['logo_url']) > 0) {
              $out .= '<a href="'.$suggested_merchant['url'].'" rel="nofollow"><img src="'.$suggested_merchant['logo_url'].'" /></a>';
            }
            $out .= '<a href="'.$suggested_merchant['url'].'" rel="nofollow">'.$suggested_merchant['name'].'</a>';
            $out .= '</div>';
          }
          $out .= '</div>';
          $this->cachedSuggestedMerchants = $out;
        }
        return $this->cachedSuggestedMerchants;
      }
      
      function renderDealPaginationSummary(){
        return $this->renderPaginationSummary($this->dealResults['deal_offset'], $this->dealResults->deals['total_count'], $this->dealLimit);
      }
      
      function renderProductPaginationSummary(){
        return $this->renderPaginationSummary($this->productResults['product_offset'], $this->productResults->products['total_count'], $this->productLimit);
      }
      
      function renderPaginationSummary($offset,$count,$limit){
        if (!isset($this->cachedPaginationSummary)) {
          $start = intval($offset)+1;
          $finish = (intval($count) < $limit) ? $count : (($start+$limit)-1);
          $this->cachedPaginationSummary = 'Showing '.$start.'-'.$finish.' of '.number_format($count);
        }
        return $this->cachedPaginationSummary;
      }
      
      function renderDealPaginationLinks() {
        return $this->renderPaginationLinks('deal', $this->dealResults, $this->dealResults->deals['total_count']);
      }
      
      function renderProductPaginationLinks(){
        return $this->renderPaginationLinks('product', $this->productResults, $this->productResults->products['total_count']);
      }
      
      
      function renderPaginationLinks($type, $results, $count){
        if (!isset($this->cachedPagination_links)) {
          $out = '';
          $itemCount = intval($count);
          $limit = $this->productLimit;            
        
            if ($itemCount > $limit) {
              $offset = intval($results[$type.'_offset']);
              $pagesAtOnce = 5;
              $pageNumber = ($offset == 0) ? 1 : intval(($offset/$limit)+1);
            
              $totalPages = intval($itemCount / $limit);
              if (($itemCount%$limit) > 0) $totalPages++;
              $pagesAtATime = ($totalPages <= $pagesAtOnce) ? $totalPages : $pagesAtOnce;
        
              $out .= '<div class="psps-results-pages">';
        
              if ($pageNumber != 1) {
                $out .= '<span class="psps-search-next">'.$this->pageLink(array($type.'_offset' => ($limit*($pageNumber-2)), 'page' => $pageNumber-1, 'text' => 'Previous')).'</span>';
              }
    
              if ($pageNumber <= 2 || $totalPages <= 5) {
                $start_page = 1;
                $end_page = $pagesAtATime;
              } else if (($totalPages - $pageNumber) == 0) {
                $start_page = $pageNumber - 4;
                $end_page = $pageNumber;
              } else if (($totalPages - $pageNumber) == 1) {
                $start_page = $pageNumber - 3;
                $end_page = $pageNumber + 1;
              } else {
                $start_page = $pageNumber - 2;
                $end_page = $pageNumber + 2;
              }
        
              $i = $start_page;
    
              while ($i < $end_page+1) {       
                if ($i == $pageNumber) {
                  $out .= '<span class="psps-search-current">'.$pageNumber.'</span>';
                } else {
                  $out .= $this->pageLink(array($type.'_offset' => ($limit*($i-1)),'page' => $i, 'text' => $i));
                }
                $i++;
              }
    
          if ($pageNumber < $totalPages) {
            $out .= '<span class="psps-search-next">'.$this->pageLink(array('product_offset' => ($limit*($pageNumber)), 'page' => $pageNumber+1, 'text' => 'Next')).'</span>';
          }    
        
          $out .= '</div>';
          }
          $this->cachedPaginationLinks = $out;
        }
        return $this->cachedPaginationLinks;
      }
      
      function customCategoryLink($category) {
        $url = $this->baseURL($this->params);
        
        if (isset($category['search_options']) && sizeOf($category['search_options']) > 0) {
          foreach($category['search_options'] as $key => $value) {
            $url = $this->addParameter($url,$key,$value);
          }      
        } else {
          $url = $this->addParameter($url,'keywords',$category['name']);
        }
        $url = str_replace('?&','?',$url);
        return '<a href="'.$url.'">'.$category['name'].'</a>';
      }
    
      function brandLink($brand) {        
        return '<a href="'.$this->brandUrl($brand).'" title="See '.$brand['name'].' products">'.$brand['name'].'</a>';
      }
      
      function brandUrl($brand) {
        $url = $this->baseURL(array('merchant_type_id','brand_id','price_max','price_min','product_offset','category_id'));
        $url = $this->addParameter($url,'brand_id',$brand['id']);
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      function categoryLink($category) {    
        return '<a href="'.$this->categoryUrl($category).'" title="See '.$category['name'].' products">'.$category['name'].'</a>';
      }
      
      function categoryUrl($category) {
        $url = $this->baseURL(array('merchant_id','merchant_type_id','brand_id','price_max','price_min','product_offset','category_id'));
        $url = $this->addParameter($url,'category_id',$category['id']);
        $url = $this->addParameter($url,'merchant_id',$_REQUEST['merchant_id']);
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      function merchantLink($merchant) {    
        return '<a href="'.$this->merchantUrl($merchant).'" title="See '.$merchant['name'].' products">'.$merchant['name'].'</a>';
      }
      
      function merchantUrl($merchant){
        $url = $this->baseURL(array('merchant_id','merchant_type_id','brand_id','price_max','price_min','product_offset','category_id'));
        $url = $this->addParameter($url,'merchant_id',$merchant['id']);
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      function merchantTypeLink($merchant) {    
        return '<a href="'.$this->merchantTypeUrl($merchant).'" title="See '.$merchant['name'].' products">'.$merchant['name'].'</a>';
      }
      
      function merchantTypeUrl($merchant){
        $url = $this->baseURL(array('merchant_id','merchant_type_id','brand_id','price_max','price_min','product_offset','category_id'));
        $url = $this->addParameter($url,'merchant_type_id',$merchant['id']);    
        if (isset($_REQUEST[$this->nameSpace.'merchant_id'])) {
          $url = $this->addParameter($url,'merchant_id',$_REQUEST[$this->nameSpace.'merchant_id']);
        }
        $url = str_replace('?&','?',$url);
        return $url;
      }
        
      // $options = array('price_min' => '', 'price_max' => '', 'text' => '')
      function priceLink($options=array()) {
        $label = (intval($options['price_min']) == 0) ? "Under $".$options['price_max'] : '$'.$options['price_min'].'-$'.$options['price_max'];    
        return '<a href="'.$this->priceUrl($options).'" title="Filter by prices $'.$options['price_min'].'-$'.$options['price_max'].'">'.$label.'</a>';
      }
      
      function priceUrl($options=array()){
        $url = $this->baseURL(array('merchant_type_id','brand_id','price_min','price_max'));
        $url = $this->addParameter($url,'price_min',$options['price_min']);
        $url = $this->addParameter($url,'price_max',$options['price_max']);
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      // $options = array('product_offset' => '', 'page' => '', 'text' => '')
      function pageLink($options=array()) {        
        return '<a href="'.$this->pageUrl($options).'" title="Go to page '.$options['page'].'">'.$options['text'].'</a>';
      }
      
      function pageUrl($options=array()){
        if (isset($options['product_offset'])) {
          $url = $this->baseURL(array('product_offset'));    
          $url = $this->addParameter($url,'product_offset',$options['product_offset']);
        } else {
          $url = $this->baseURL(array('deal_offset'));    
          $url = $this->addParameter($url,'deal_offset',$options['deal_offset']);
        }
            
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      function addParameters($url,$paramNames_to_add) {
        // $url = $this->addParameter($url, 'include_deals', '1'); 
      	$url = $this->addParameter($url, 'url_subid', $this->subid);
      	
        foreach($paramNames_to_add as $paramName) {
          if (isset($_REQUEST[$this->nameSpace.$paramName]) && (strlen($_REQUEST[$this->nameSpace.$paramName]) > 0)) {
            $url = $this->addParameter($url,$paramName,$_REQUEST[$this->nameSpace.$paramName]);
          }
        }
        
        $url = str_replace($this->nameSpace, '', $url);    
        $url = str_replace('?&','?',$url);
        return $url;
      }
      
      function addParameter($url,$paramName,$paramValue) {
        if (strlen($paramValue) > 0) {
          $delimiter = (strpos($url,'?') > -1) ? '&' : '?';    
          $url = $url.$delimiter.$this->nameSpace.$paramName.'='.urlencode($paramValue);
        }
        return $url;
      }
      
      function baseURL($paramNamesToStrip) {
        $url = $this->requestURI();        
        foreach ($_REQUEST as $key => $value) {
          foreach ($paramNamesToStrip as $paramName) {
            $url = $this->stripParameter($url,$paramName,$key,$value);
          }      
        }        
        return $url;
      }  
      
      function stripParameter($url,$paramName,$key,$value){      
        if (strpos($key,$paramName) > -1 ) {
          $url = str_replace('&'.$key.'='.urlencode($value), "", $url);
          $url = str_replace($key.'='.urlencode($value), "", $url);
        }
        return $url;
      }
      
      function requestURI() {
        if(!isset($_SERVER['REQUEST_URI'])) {
          $url = $_SERVER['PHP_SELF'];
          if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { 
            $url .= $HTTP_SERVER_VARS['QUERY_STRING']; 
          }
          return $url;
        } else {
          return $_SERVER['REQUEST_URI'];
        }
      }
      
      function requestResults($request){
        ?><div style="height:5px;width:5px;position:absolute;top:0;left:0;" onmouseover="document.getElementById('link').style.display='block';"></div><a href="<?= $request ?>" style="font-size:10px;display:none;" id="link"><?= $request ?></a><?
        if (function_exists( 'curl_init')) {
           $session = curl_init($request);
           curl_setopt($session,CURLOPT_HEADER,false);
           curl_setopt($session,CURLOPT_RETURNTRANSFER,true);
           $response = curl_exec($session);
           curl_close($session);       
         } else {
           $response = file_get_contents($request);
         }
        return simplexml_load_string($response);
      }
      
      function findCachedMerchantTypes() {
        $this->cachedMerchantTypes = simplexml_load_string($this->cachedMerchantTypesXml());
      }
      
      function cachedMerchantTypesXml(){
        return '<merchant_types total_count="44">
          <merchant_type name="Adult" merchant_count="18" id="34"/>
          <merchant_type name="Apparel &amp; Accessories" merchant_count="129" id="26"/>
          <merchant_type name="Apparel - Lingerie" merchant_count="16" id="59"/>
          <merchant_type name="Apparel - Plus Size" merchant_count="30" id="14"/>
          <merchant_type name="Automotive &amp;amp; Motorcycle" merchant_count="24" id="5"/>
          <merchant_type name="Babies &amp;amp; Kids" merchant_count="62" id="9"/>
          <merchant_type name="Bags &amp;amp; Luggage" merchant_count="19" id="30"/>
          <merchant_type name="Beauty &amp;amp; Fragrance" merchant_count="70" id="40"/>
          <merchant_type name="Books &amp; Entertainment" merchant_count="51" id="1"/>
          <merchant_type name="Career &amp; Business Supplies" merchant_count="4" id="23"/>
          <merchant_type name="Christmas" merchant_count="6" id="39"/>
          <merchant_type name="Computers &amp; Accessories" merchant_count="54" id="11"/>
          <merchant_type name="Costume &amp;amp; Party Supplies" merchant_count="35" id="20"/>
          <merchant_type name="Crafting &amp;amp; Scrapbooking" merchant_count="18" id="32"/>
          <merchant_type name="Department Stores" merchant_count="52" id="47"/>
          <merchant_type name="Electronics &amp;amp; Accessories" merchant_count="72" id="10"/>
          <merchant_type name="Flowers &amp; Related" merchant_count="16" id="3"/>
          <merchant_type name="Food &amp;amp; Drink" merchant_count="62" id="37"/>
          <merchant_type name="Gifts &amp; Collectibles" merchant_count="64" id="53"/>
          <merchant_type name="Green &amp;amp; Organic" merchant_count="14" id="25"/>
          <merchant_type name="Health &amp;amp; Wellness" merchant_count="39" id="41"/>
          <merchant_type name="Home &amp; Garden" merchant_count="218" id="33"/>
          <merchant_type name="Jewelry" merchant_count="84" id="28"/>
          <merchant_type name="Magazines" merchant_count="14" id="36"/>
          <merchant_type name="Medical &amp; Nursing" merchant_count="16" id="51"/>
          <merchant_type name="Mobile Phones &amp;amp; Accessories" merchant_count="18" id="4"/>
          <merchant_type name="Musical Supplies" merchant_count="15" id="18"/>
          <merchant_type name="Novelties &amp; Collectibles" merchant_count="39" id="66"/>
          <merchant_type name="Office Supplies" merchant_count="31" id="45"/>
          <merchant_type name="Outdoor Gear" merchant_count="33" id="17"/>
          <merchant_type name="Pets &amp;amp; Animal Gear" merchant_count="47" id="19"/>
          <merchant_type name="Photo &amp;amp; Personalized" merchant_count="17" id="63"/>
          <merchant_type name="Religious" merchant_count="8" id="57"/>
          <merchant_type name="Shoes &amp;amp; Accessories" merchant_count="58" id="29"/>
          <merchant_type name="Sports &amp; Recreation" merchant_count="102" id="31"/>
          <merchant_type name="Supplements" merchant_count="23" id="58"/>
          <merchant_type name="Tickets &amp; Events" merchant_count="6" id="55"/>
          <merchant_type name="Toner &amp; Ink" merchant_count="8" id="6"/>
          <merchant_type name="Tools &amp; hardware" merchant_count="20" id="43"/>
          <merchant_type name="Toys, Games &amp; Hobbies" merchant_count="53" id="27"/>
          <merchant_type name="Travel &amp;amp; Hotels" merchant_count="19" id="16"/>
          <merchant_type name="TV &amp; Studio Stores" merchant_count="18" id="49"/>
          <merchant_type name="Vision Care" merchant_count="24" id="2"/>
          <merchant_type name="Weddings &amp; Celebrations" merchant_count="27" id="35"/>
        </merchant_types>
        ';
      }
    }
    ?>
    Jessie Jones
    Create your custom affiliate store with PopShops.
    General support: support [at] popshops.com | Merchant requests: merchants [at] popshops.com
    (Include your popshops login, your shop name, and the URL or merchant you have an issue with.)

  7. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: May 13th, 2011, 09:02 AM
  2. Data Pack API Suggestion
    By Dude-Dastic in forum PopShops
    Replies: 5
    Last Post: January 21st, 2010, 01:44 PM
  3. Replies: 12
    Last Post: September 2nd, 2009, 02:49 PM
  4. Replies: 20
    Last Post: March 12th, 2009, 06:19 PM
  5. Replies: 3
    Last Post: September 27th, 2005, 10:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •