Skip Navigation

[Resolved] Creating a Child Post Type to Woocommerce Products

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

Problem:
1) Can I integrate Gravity form submission to Toolset Views? How can I achieve this?

2) Can I query user related fields created by Ultimate Member when displaying a View? I.e. User name/ whether user is logged in etc. What are my limitations from not using the CRED user function

3) From what I understand, Coffee Reviews need to be the Child Type for Woocommerce Product. Is this possible since Product was not created by Types?

4) Can you briefly outline the suggested steps I should take to achieve my aim of creating a User Submitted Coffee Review in the following conditions:
i) Using the current plugins that I already have and incorporating Toolset.
ii) If (i) is not possible, how can I achieve this with minimal changes from my original plan.

Solution:
1) Can I integrate Gravity form submission to Toolset Views? How can I achieve this?
Yes, you can integrate it. Let's assume you use Types to create a custom post type. Views will automatically detect that custom post type, and it will begin to appear in the Content Selection area of Views. Any custom fields you define for that post type in Types will begin to show up in your Views filters and content shortcode options. So most of the background integration is already set up for you in Views and Types. If you use Gravity to create posts in this custom post type, and set up the forms to populate custom fields correctly, then your Views should be able to access this information just as if the posts were created by Types. Types stores its custom field data in the postmeta table using the prefix "wpcf-", so if your custom field slug in Types is "someslug" then your custom field slug in the database should be "wpcf-someslug". So if you have custom fields in your Gravity form submission, they should follow the same syntax and use the "wpcf-" prefix.

2) Can I query user related fields created by Ultimate Member when displaying a View? I.e. User name/ whether user is logged in etc. What are my limitations from not using the CRED user function
If you tell Types to manage these custom fields in User Field Control, you can set up predefined query filters for Views based on them. For instance, you could set up a View that displays all Users with a custom field value of "abc". However, Views does not support filtering User Views on the front-end in a custom search form. That's the case for User fields created by Types as well, it's just currently a limitation of Views. You can display information from these fields and use them in conditional HTML, no problem. More information about displaying User fields here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user
https://toolset.com/documentation/customizing-sites-using-php/functions/

3) From what I understand, Coffee Reviews need to be the Child Type for Woocommerce Product. Is this possible since Product was not created by Types?
Yes, it's possible to create a child of the Product post type. You could set up your reviews this way.

4) Can you briefly outline the suggested steps I should take to achieve my aim of creating a User Submitted Coffee Review in the following conditions:
i) Using the current plugins that I already have and incorporating Toolset.
ii) If (i) is not possible, how can I achieve this with minimal changes from my original plan.

It should be possible. Very briefly:
- Create your custom post type in Toolset > Post Types
- Add any custom fields you want to capture along with the review in Toolset > Post Fields (rating, flavor profile, etc)
- Create a Gravity Form form that is set up to create Review posts and capture any custom fields necessary. I can't help you much here, but I can provide you the slugs necessary to create any custom field you define in Types. The parent post association is stored in the postmeta table with the child post ID, using the syntax "_wpcf_belongs_parentslug_id", and the value should be the parent post ID.
- Place your Gravity Form on the Product page
If creating the Gravity Form is a major issue, we can help you set up a CRED form instead.

- Woocommerce product subcategory page (Coffee Roasters) (filtered by the Coffee Roaster) - p/s: Should this be a post type?
It depends. For example, Taxonomy-based filters are a bit more flexible in Views, but post types have built-in single post pages and can be managed with CRED. I recommend reviewing this article that discusses the difference between taxonomies and post types, and when each is recommended: http://www.wpbeginner.com/beginners-guide/when-do-you-need-a-custom-post-type-or-taxonomy-in-wordpress/

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user
https://toolset.com/documentation/customizing-sites-using-php/functions/
http://www.wpbeginner.com/beginners-guide/when-do-you-need-a-custom-post-type-or-taxonomy-in-wordpress/

This support ticket is created 7 years, 1 month 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#580807

Hi,

First of all I would like to express both my admiration for Toolset plugin which is so versatile and my frustration that I did not come across this plugin during the earlier stages of my site.

My aim is to build a Coffee Community/e-commerce site with the following functions
1) Retail of coffee beans and equipments
2) User submitted Coffee reviews
3) Membership function where users can have their own profile/records

I am using Woocommerce to achieve function 1 and Ultimate Member plugin to achieve function 3.

My issue now is with Function number 2. Here is what I am trying to achieve for the coffee reviews.

Users are able to submit reviews from
-the Woocommerce single Product page
-Their Ultimate Member profile page

Coffee Reviews can then be viewed from
- Woocommerce single product page (filtered to reviews related to the product)
- Woocommerce product subcategory page (Coffee Roasters) (filtered by the Coffee Roaster) - p/s: Should this be a post type?
- Ultimate member profile page ( filtered to reviews submitted by them)
- An Archive page to list all the Coffee Reviews - which can be sorted accordingly

I was initially planning to use Gravity Form to allow submission and then Gravity View plugin to display the submissions. In fact, I have created an elaborate form using Gravity Form for this purpose. Creating a custom post type was not in my initial plan. However, I am currently hitting a roadblock as I feel the complexity of the project calls for the use of a custom post type to better manage the data. After reading through the Toolset documentation, I realized that toolset would have been the perfect plugin for all the objectives I mentioned above but having come this far, I hope there is a way to incorporate Toolset to my current project.

I would like to seek clarifications for the questions below:

1) Can I integrate Gravity form submission to Toolset Views? How can I achieve this?

2) Can I query user related fields created by Ultimate Member when displaying a View? I.e. User name/ whether user is logged in etc. What are my limitations from not using the CRED user function

3) From what I understand, Coffee Reviews need to be the Child Type for Woocommerce Product. Is this possible since Product was not created by Types?

4) Can you briefly outline the suggested steps I should take to achieve my aim of creating a User Submitted Coffee Review in the following conditions:
i) Using the current plugins that I already have and incorporating Toolset.
ii) If (i) is not possible, how can I achieve this with minimal changes from my original plan.

Thank you in advance for your much appreciated guidance.

#580888

Hi! Thanks for considering Toolset. I'll try to answer your questions. In the future, we kindly ask you to limit each ticket to one question / issue. This will get you the most targeted support, and help keep the forum organized so other users with similar questions can find answers here. Please review my answers below.

1) Can I integrate Gravity form submission to Toolset Views? How can I achieve this?
Yes, you can integrate it. Let's assume you use Types to create a custom post type. Views will automatically detect that custom post type, and it will begin to appear in the Content Selection area of Views. Any custom fields you define for that post type in Types will begin to show up in your Views filters and content shortcode options. So most of the background integration is already set up for you in Views and Types. If you use Gravity to create posts in this custom post type, and set up the forms to populate custom fields correctly, then your Views should be able to access this information just as if the posts were created by Types. Types stores its custom field data in the postmeta table using the prefix "wpcf-", so if your custom field slug in Types is "someslug" then your custom field slug in the database should be "wpcf-someslug". So if you have custom fields in your Gravity form submission, they should follow the same syntax and use the "wpcf-" prefix.

2) Can I query user related fields created by Ultimate Member when displaying a View? I.e. User name/ whether user is logged in etc. What are my limitations from not using the CRED user function
If you tell Types to manage these custom fields in User Field Control, you can set up predefined query filters for Views based on them. For instance, you could set up a View that displays all Users with a custom field value of "abc". However, Views does not support filtering User Views on the front-end in a custom search form. That's the case for User fields created by Types as well, it's just currently a limitation of Views. You can display information from these fields and use them in conditional HTML, no problem. More information about displaying User fields here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user
https://toolset.com/documentation/customizing-sites-using-php/functions/

3) From what I understand, Coffee Reviews need to be the Child Type for Woocommerce Product. Is this possible since Product was not created by Types?
Yes, it's possible to create a child of the Product post type. You could set up your reviews this way.

4) Can you briefly outline the suggested steps I should take to achieve my aim of creating a User Submitted Coffee Review in the following conditions:
i) Using the current plugins that I already have and incorporating Toolset.
ii) If (i) is not possible, how can I achieve this with minimal changes from my original plan.

It should be possible. Very briefly:
- Create your custom post type in Toolset > Post Types
- Add any custom fields you want to capture along with the review in Toolset > Post Fields (rating, flavor profile, etc)
- Create a Gravity Form form that is set up to create Review posts and capture any custom fields necessary. I can't help you much here, but I can provide you the slugs necessary to create any custom field you define in Types. The parent post association is stored in the postmeta table with the child post ID, using the syntax "_wpcf_belongs_parentslug_id", and the value should be the parent post ID.
- Place your Gravity Form on the Product page
If creating the Gravity Form is a major issue, we can help you set up a CRED form instead.

- Woocommerce product subcategory page (Coffee Roasters) (filtered by the Coffee Roaster) - p/s: Should this be a post type?
It depends. For example, Taxonomy-based filters are a bit more flexible in Views, but post types have built-in single post pages and can be managed with CRED. I recommend reviewing this article that discusses the difference between taxonomies and post types, and when each is recommended: hidden link

Let me know your thoughts.

#581233

Hi Christian,

I do apologize for asking multiple questions in a single post. However, thanks to your reply i have gain a better understanding on how to proceed with my project.
I have tested with Toolsets functions throughout the past few days and came to the decision that it would be too much effort to restart my project with Layouts and CRED. I will continue to use Types and Views and implement its functions through PHP.
I'm new to PHP, so I see myselg fielding more questions soon.

Thanks!