get_post_type() and WooCommerce (2 posts)

  1. piglesias
    Posted 3 years ago #


    I'm developing a site + store using Canvas theme and Woocommerce.

    Now, I'm trying to implement Zopim live chat just in store and regular pages (not into the blog). In the previous version of this site running WP-Commerce I did it using this code in the footer.php:

    <?php if ( is_page('') | is_post_type('wpsc-product') ) {?>
    <!--here goes the chat javascript-->
    <?php }?>

    Well, If I try this in woocommerce:

    <?php if ( is_page('') | is_post_type('product') ) {?>
    <!--here goes the chat javascript-->
    <?php }?>

    It breaks at is_post_type('').

    So I tried via get_post_type() and a filter in the functions.php file:

    add_action( 'woo_footer_after', 'closefooterwrap', 10 );
    function closefooterwrap () {
        echo '</div>';
      $tipo = get_post_type();
        if ( is_page() | $tipo == 'product' ) {

    But get_post_type(); retursns 'product' type almost everywhere in the site! Even in blog post! So the chat displays everywhere. :-(

    Anybody has got any idea about how to solve this?

    Thank you very much in advance.


  2. mtphoto
    Posted 3 years ago #

    I was able to use the documentation here to target only store single product pages for WP E-commerce. If you know the corresponding tag for Woo Commerce, then it will probably work.

    WordPress Ecommerce - Checking if on a product page

Topic Closed

This topic has been closed to new replies.

About this Topic