Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Questions
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 21st, 2015, 11:05 AM
creativa creativa is offline
 
Join Date: Nov 2014
Posts: 12
Default 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...
  #2  
Old January 21st, 2015, 11:22 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

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
  #3  
Old January 21st, 2015, 11:48 AM
creativa creativa is offline
 
Join Date: Nov 2014
Posts: 12
Default

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?
  #4  
Old January 21st, 2015, 12:35 PM
creativa creativa is offline
 
Join Date: Nov 2014
Posts: 12
Default

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!
  #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
  #6  
Old January 23rd, 2015, 09:13 AM
creativa creativa is offline
 
Join Date: Nov 2014
Posts: 12
Default 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!
  #7  
Old January 23rd, 2015, 09:36 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

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
  #8  
Old January 23rd, 2015, 09:54 AM
creativa creativa is offline
 
Join Date: Nov 2014
Posts: 12
Default

Thank you
  #9  
Old February 3rd, 2015, 12:14 AM
creativa creativa is offline
 
Join Date: Nov 2014
Posts: 12
Default

Hello Eric,

Can we create Comparison sets in bulk?

Thanks.
  #10  
Old February 3rd, 2015, 08:00 AM
stefan stefan is offline
 
Join Date: Feb 2008
Posts: 5,901
Default

Quote:
Originally Posted by creativa View Post
Can we create Comparison sets in bulk?
That's not possible.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coupons globie Questions 4 February 14th, 2014 03:11 AM
Using Coupons youngy Questions 2 February 20th, 2013 08:37 AM
Coupons kargz12 Problems 4 March 20th, 2012 12:22 PM
Coupons? lesljr Questions 2 March 13th, 2012 04:11 PM


All times are GMT -5. The time now is 03:17 AM.


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