View Single Post
  #5  
Old January 21st, 2015, 01:29 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by creativa View Post
What exactly does the 250 represent?
It means if the number of characters returned by the datafeedr_tag() function is greater than 250, display the coupons. If it's less than 250, that probably means there are no coupons.

Quote:
Originally Posted by creativa View Post
I have one more question: When on a Category page, we want to have the same functionality with the coupons, but instead we want to show an icon on all those products whose Merchant has coupons.
You're almost there... first make sure you clear your cache to view the page. I see the "C" link in a circle on those pages. I see it after I refresh the cache here: http://www.atletikka.com/store/categ...ing/?refresh=2

The other issue is that you can't have more than 1 CSS ID per page. But you have id="coupons". That is the reason when you click the "C" link you only get Amazon coupons.... Amazon coupons are the first loaded on the page.

You could try something like:

HTML Code:
<?php $coupons = datafeedr_tag('Coupons?merchant='.$product->merchant).'&c=1456737'; ?>
<?php $css_id = 'coupons-' . $product->merchant; ?>
<?php if ( strlen( $coupons ) > 250 ) : ?>
  <div class="sale-mask">
    <a class="fancybox" href="#<?php echo $css_id; ?>">C</a>
    <div id="<?php echo $css_id; ?>" style="display:none;width:800px;">
      <div id="view">
        <?php echo $coupons; ?>
      </div>
    </div>
  </div>
<?php endif; ?>
That will get you a little closer. However you will still have duplicate CSS IDs on the page so you might have to actually generate a random string using something like mt_rand() or similar like this:

HTML Code:
<?php $coupons = datafeedr_tag('Coupons?merchant='.$product->merchant).'&c=1456737'; ?>
<?php $css_id = 'coupons-' . $product->merchant . '-' . mt_rand(); ?>
<?php if ( strlen( $coupons ) > 250 ) : ?>
  <div class="sale-mask">
    <a class="fancybox" href="#<?php echo $css_id; ?>">C</a>
    <div id="<?php echo $css_id; ?>" style="display:none;width:800px;">
      <div id="view">
        <?php echo $coupons; ?>
      </div>
    </div>
  </div>
<?php endif; ?>
That should at least get you in the ballpark.

Eric