WordPress.org

Forums

WooCommerce - excelling eCommerce
is_woocommerce, is_cart & is_checkout conditional tags broken (1 post)

  1. nightbook
    Member
    Posted 1 year ago #

    Hello,

    I'm trying to use the WooCommerce Conditional Tags:
    http://docs.woothemes.com/document/conditional-tags/

    I'm attempting to implement conditional Google AdWords Conversion code, my is_front_page and is_page conditions are working fine, but is_cart/is_checkout doesn't include the code:

    <?php
    	$google_conversion_id = 986952114;
    	if (is_front_page()) {
    		$google_conversion_label = "mB_CCM7akggQsuPO1gM";
    	} elseif (is_page(9335)) {
    		$google_conversion_label = "-AbhCObXkggQsuPO1gM";
    	} elseif (is_cart()) {
    		$google_conversion_label = "nT4bCO7WkggQsuPO1gM";
    	} elseif (is_checkout()) {
    		$google_conversion_label = "ZLSeCPbVkggQsuPO1gM";
    	}
    	if ($google_conversion_label && $google_conversion_label != ""):
    ?>
    <!-- Google Code for Conversion Page -->
    <script type="text/javascript">
    	/* <![CDATA[ */
    		var google_conversion_id = <?php echo $google_conversion_id;?>;
    		var google_conversion_language = "en";
    		var google_conversion_format = "3";
    		var google_conversion_color = "ffffff";
    		var google_conversion_label = "<?php echo $google_conversion_label;?>";
    		var google_remarketing_only = false;
    	/* ]]> */
    </script>
    <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
    <noscript>
    	<div style="display:inline;">
    		<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/<?php echo $google_conversion_id;?>/?label=<?php echo $google_conversion_label;?>&guid=ON&script=0"/>
    	</div>
    </noscript>
    <?php endif; ?>

    This should include the Google Code for Conversion Page onto my cart and checkout pages through the is_cart and is_checkout conditionals:
    http://whalecontentstudio.com/cart/
    http://whalecontentstudio.com/checkout/
    *I've tried even with them populated with product or subscription through our packages page:
    http://whalecontentstudio.com/subscriptions-pricing/

    Also tried the following woo & wp conditionals with no luck;
    is_woocommerce()
    is_page('cart') / is_page('checkout')
    is_page(ID)
    is_page(wc_get_page_id( 'cart' ))
    is_page(wc_get_page_id(ID))

    I've had no luck with any, not only are the woo conditionals not working, but the is_page doesn't seem to recognize the page by it's slug or it's ID.

    Any ideas appreciated,
    Thanks

    https://wordpress.org/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic