Skip Navigation

[Resolved] Display non-Toolset fields

This thread is resolved. Here is a description of the problem and solution.

Problem:
The issue here is that the user wanted to display Non-toolset fields.

Solution:

You should be able to do this by using the shortcode in the link below.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153444

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 30 replies, has 2 voices.

Last updated by Shane 6 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1091358

Uuugh. No, it doesn't work. Does it work on your side?

Sincerely, Mika

#1091380

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

#1091423

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

#1092973

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

#1093064

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

#1093197

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

#1093202

Seems that cannot use it in conditional output as a condition.

#1093206

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

#1093693

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

#1093694
example-1.JPG

Screenshot here

#1093770

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

#1093804

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

#1094089

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

#1094577

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

#1095086

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