Datafeedr Support Forums

Datafeedr Support Forums (http://www.datafeedr.com/forums/index.php)
-   Questions (http://www.datafeedr.com/forums/forumdisplay.php?f=67)
-   -   PHP Conditionals for Coupons (http://www.datafeedr.com/forums/showthread.php?t=11468)

creativa January 21st, 2015 11:05 AM

PHP Conditionals for Coupons
 
Website URL: www.atletikka.com
URL to page in question: http://www.atletikka.com/store/women...2900738910684/


Hi, I'm trying to set a PHP If() Conditional on the Product Detail Page where IF a Merchant is offering Coupons/Promotions, THEN a link will appear on page that when clicked, it will open up a window with the coupons available for that particular Merchant.

Right now, for the purpose of giving you an example, I have a PHP Conditional based on the Sale Price of the product. So, you'll notice that if a product is on sale, the word Coupon appears next to the price and that opens up the window with the available coupons. But when you click another product that is not on sale, you don't see the Coupons links anymore. So I want to do the same thing, but with the right PHP Conditionals.

This is the Code I have so far:

<?php if ($product->saleprice > 0 && $product->saleprice < $product->price) : ?>
<div>
<a class="fancybox" href="#test">Coupons</a>

<div id="test" style="display:none;width:800px;">
<div id="view">
<?php echo datafeedr_tag('Coupons?merchant='.$product->merchant.'&c=1456737'); ?>
</div>
</div>
</div>
<?php endif; ?>

</div>
</div>



Thanks for your help...

Eric January 21st, 2015 11:22 AM

Hi

I think this will work though you might have to tweak the value 250...

In your Product Details view, change this:

HTML Code:

    <?php if ($product->saleprice > 0 &&  $product->saleprice < $product->price) : ?>
 <div>
  <a class="fancybox" href="#test">Coupons</a>

    <div id="test" style="display:none;width:800px;">
      <div id="view">
        <?php echo datafeedr_tag('Coupons?merchant='.$product->merchant.'&c=1456737'); ?>
      </div>
    </div>
 </div>
    <?php endif; ?>

To this:

HTML Code:

<?php $coupons = datafeedr_tag('Coupons?merchant='.$product->merchant.'&c=1456737'); ?>
<?php if ( strlen( $coupons ) > 250 ) : ?>
        <div>
                <a class="fancybox" href="#test">Coupons</a>
                <div id="test" style="display:none;width:800px;">
                        <div id="view">
                                <?php echo $coupons; ?>
                        </div>
                </div>
        </div>
<?php endif; ?>

Hopefully that gets you there!

Eric

creativa January 21st, 2015 11:48 AM

Great! That did the trick. Thank you! One quick question: When you say that...


Quote:

I think this will work though you might have to tweak the value 250...
What exactly does the 250 represent?

creativa January 21st, 2015 12:35 PM

URL to page in question: http://www.atletikka.com/store/category/running/

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. See link above to see where we are with this. So it would be pretty much the same concept as on the Product Detail Page, but this time on the Category Pages and with a Coupon Icon that will show up when that Merchant has Coupons and will open up the popup window when clicked.

This is what we have so far:

HTML Code:

<?php $coupons = datafeedr_tag('Coupons?merchant='.$product->merchant).'&c=1456737'; ?>
<?php if ( strlen( $coupons ) > 250 ) : ?>
  <div class="sale-mask">
    <a class="fancybox" href="#coupons">C</a>
    <div id="coupons" style="display:none;width:800px;">
      <div id="view">
        <?php echo $coupons; ?>
      </div>
    </div>
  </div>
<?php endif; ?>

Thanks again!

Eric January 21st, 2015 01:29 PM

Quote:

Originally Posted by creativa (Post 52773)
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 (Post 52774)
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

creativa January 23rd, 2015 09:13 AM

Comparison Sets
 
URL to page in question: http://www.atletikka.com/store/searc...ike+reax+run+9

Hi Eric! Thank you so much for helping me resolve our issues. It works great now! Now I have one more request that has to do with the Comparison Sets.

Now that the coupons popup window is working, we are adding a feature that when the product has a comparison set, it will show a tab next to the coupon tab inside the popup window called Compare. If you go to the page listed above, and click on one of the coupons button on one of the products that has a COMPARE button at the bottom, you'll see what we want to accomplish.

So far we added an the IF () statement that when the product has a comparison set, it will add the Compare tab, and if it doesn't it will not. You can try this by clicking on the coupons button on another product that doesn't have the Compare button at the bottom and you'll see that the only tab that shows up is the Coupons tab.

But now the situation is that when you click on the Compare tab, I was only able to get it to work with one compset_id, and not for the compset for that particular product. So that's where I need your help. I need the Compare tab to show the comparison set of the selected product.

Here's the code that I have in place:

HTML Code:

<div class="compare">
        <?php if ( $product->compset_status > 0 ) : ?>
                    [tabs][tab title="Coupons"]<?php echo $coupons; ?>[/tab] [tab title="Compare"][DFR:compset?compset_id=56261][/tab][/tabs]
<?php else : ?>
  [tabs][tab title="Coupons"]<?php echo $coupons; ?>[/tab][/tabs]
<?php endif; ?>
        </div>


And one more question, which you've probably gotten many times: Is there a way to automate the comparison sets in any way? Or is there a way to make do the comparisons in an easier and faster way?

Thanks in advance!

Eric January 23rd, 2015 09:36 AM

Hi

You should be able to pass the product ID to the shortcode.

Code:

[DFR:compset?p=1234567890987654321]
Where 1234567890987654321 is the product ID.

That should build the compset based on the product.

Unfortunately there's no way to automate comp sets.

Eric

creativa January 23rd, 2015 09:54 AM

Thank you

creativa February 3rd, 2015 12:14 AM

Hello Eric,

Can we create Comparison sets in bulk?

Thanks.

stefan February 3rd, 2015 08:00 AM

Quote:

Originally Posted by creativa (Post 52981)
Can we create Comparison sets in bulk?

That's not possible.


All times are GMT -5. The time now is 12:52 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.