Forums

WooCommerce - excelling eCommerce
Get product type (check is it "external") for further action (3 posts)

  1. dovich
    Member
    Posted 6 months ago #

    Hi!

    I'm trying set the condition in the header in my template. When customer enter the product page and the product type is "external", then some block appears in header.

    Here's how I tried to implement it (the code goes right after <body> tag in header.php):

    <?php global $product;
          if (is_product() and $product->product_type == 'external') : ?>
          <div>Some info for external products</div>
    <?php endif; ?>

    But it doesn't work. Can somebody help me whith this issue? I'm not familiar with wordpress so good and can be some stupid mistake in my code.

    Thanks in advance.

    http://wordpress.org/extend/plugins/woocommerce/

  2. helgatheviking
    Member
    Posted 6 months ago #

    is the $product set up yet? if you var_dump($product) do you get anything in the array? if not, then i suspect that you are calling this before setup_post which if i remember is where the product data is defined.

  3. dovich
    Member
    Posted 6 months ago #

    How can I set up it in header? var_dump($product) shows me only product title, meanwhile if i call var_dump directly on product page, it shows me a huge array.

Reply

You must log in to post.

About this Plugin

About this Topic