Uuugh. No, it doesn't work. Does it work on your side?
Sincerely, Mika
Hi Shane,
Let's do so that I'll organize demo site for your next Monday, so that you can play around and test it.
Agree?
Sincerely, Mika
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mika,
Yes it works on my side.
I was able to get what type of product it is and use the conditional to display based on the product type.
But yes please set this up so that I can do the tests there. The private fields have been enabled for you to do this.
Thanks,
Shane
Hi Shane,
It works! I got also "1" when product type is same (otherwise nothing). I missed probably something last Friday. Sorry.
I couldn't display product_type with Views. How you display it?
Sincerely, Mika
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mika,
Actually it doesn't seem that there is a way to display the product type explicitly.
What you will probably need to do is use the custom shortcode in combination with our conditional code to display the product type.
Meaning If the product type matches what you are checking for then display the hardcoded text.
Please let me know if this helps.
Thanks,
Shane
Hi Shane,
I can get it with following code:
/**
* Add shortcode for product type
*/
function displayProductType() {
global $product;
$product_id = $product->get_id(); // The product ID
return get_the_term_list( $product_id, 'product_type');
}
add_shortcode('product_type', 'displayProductType');
And then display in Views:
[product_type id='[wpv-post-id]']
I'm not sure this is right way of doing it but seems to work. Any comments?
Sincerely, Mika
Seems that cannot use it in conditional output as a condition.
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mika,
What is the exact output of this shortcode?
To me it seems that it will return a wordpress object. What exactly does it return on the page?
Please let me know.
Thanks,
Shane
Hi Shane,
It returns WC products type like 'simple' or 'auction'. See attached screenshot.
Any idea how to use it in conditional output as a condition?
Sincerely, Mika
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mika,
Thank you for the clarity.
Given that this is a custom shortcode. It needs to be added to the views 3rd party shortcode arguments in Toolset -> Settings -> Frontend . Once you add the name of the shortcode here then it should start working in our conditional output.
Also since you are using the global $product variable then you don't need to pass the [wpv-post-id] shortcode into the function since your shortcode does not take a parameter.
Please let me know if this has been helpful so far or if there are any concerns or questions.
Thanks,
Shane
Hi Shane,
It is product_type is defined in the settings as you describe but I can't get it working. I'm using below sentence in Views.
[wpv-conditional if="( '[product_type]' eq 'auction' )"]<p>[wpv-post-author]</p>[/wpv-conditional]
Any suggestions?
Sincerely, Mika
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mika,
Could you add debug='true' to the conditional shortcode. Like this -> [wpv-conditional if="( '[product_type]' eq 'auction' )" debug=true'']<p>[wpv-post-author]</p>[/wpv-conditional]
Then check on the frontend and send me a screenshot of the returned debug statement.
Thanks,
Shane
Hi Shane,
I tried [wpv-conditional if="( '[product_type]' eq 'auction' )" debug="true"]<p>Myyjä: [wpv-post-author]</p>[/wpv-conditional] but it doesn't give debug info. Just blank screen where the output should be.
Sincerely, Mika
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mika,
Thats strange.
Is it possible for me to log in and check this ? It would be much faster if I could have a look and then see if I can get a better understanding of whats wrong.
Given that the shortcode returns results in a view then it should work normally.
I've enabled the private fields.
Thanks,
Shane