I'm beginning to understand. The 3rd party plugin that I am using has created a product type (Event Tickets) that is in addition to the standard Woo products. The Event Tickets product has fields that I'd like to Hide on the Front End if the product type is not Tickets.
So how do I find out what is the code for the Event Ticket product type. With this information, I could create a conditional that would hide the field if it has the word "event_tickets".
I checked the custom fields available on the post and tickets was not on the list and neither is it on the hidden fields..
Hello,
I don't know how this 3rd party plugin works, so I can't really suggest what to do.
Just remember that:
- Toolset plugins can handle only content created with Toolset. Maybe it won't be able to offer the same features for the custom post types created by other plugins.
- Toolset custom fields are prefixed by "wpcf-" in the database. A Toolset field "Name" with slug "name", will be stored in a meta_key "wpcf-name".
- You can use your custom shortcodes or functions inside Toolset conditionals. You can also nest and combine conditions. Check the following articles:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-shortcodes-in-conditions/
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-custom-functions-in-conditions/
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/nesting-and-combining-conditions/
You will need to inspect the database to understand how this plugin connects products and events. You may want to ask the plugin's authors/support about it.
Then you can create your own function or shortcode and use it inside your conditions to show/hide what you want.
I hope this makes sense. Let me know if you have any doubts.
Hi Jamal
The good news is that I figured out the product type. I believe it is ticket-event, per the views code (attached). I tried to create a conditional display to display a field only if the product type is 'ticket-event'. However, I must have typed something wrong because it does not work. I read that the ticket-event is a string..does that make a difference?
This is what I wrote using your guidance:
[wpv-conditional if="( '[wpv-post-field name='product_type']' eq 'ticket-event' )"] this is a ticket [/wpv-conditional]
[wpv-conditional if="( '[wpv-post-field name='product_type']' ne 'ticket-event' )"] this is not ticket [/wpv-conditional]
2) I also tried to do something using post taxonomies but got stuck.
I read through all the documentation and the tutorials and this one doesn't fit cleanly on the examples. I need guidance.
Thank you
I believe product_type is a taxonomy instead of custom field
[wpv-post-taxonomy type='product_type' format='name']
Can you try the following code:
[wpv-conditional if="( '[wpv-post-taxonomy type='product_type' format='name']' eq 'ticket-event' )"] this is a ticket [/wpv-conditional]
[wpv-conditional if="( '[wpv-post-taxonomy type='product_type' format='name']' ne 'ticket-event' )"] this is not ticket [/wpv-conditional]
If it does not work, use format='slug' in '[wpv-post-taxonomy].