Skip Navigation

[Resolved] Displaying data from parent post type in CRED form

This support ticket is created 6 years, 2 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#602474
Screen Shot 2018-01-02 at 8.06.06 am.png

Tell us what you are trying to do?
===========================
I am building a website for a printer who takes stationery orders on line from his clients. One such client (called "MAX") has approx 130 offices and regularly orders business cards, letterheads, etc.

I have setup a CPT called "Max Offices" which holds details of these offices - such as address, phone, etc - all the details that would appear on business stationery. I have worked out how to add new offices and also to edit details of existing offices. 🙂 All good.

I have setup another CPT called "Max Orders" which will hold the details of the orders placed on line thru the form I've created using CRED.

"Max Orders" is setup as a child of "Max Offices".

As shown in the included screenshot, the first action in the Max Orders form, is to select the parent office. In the example shown, I have selected the office in the city called "Ayr".

What I want to be able to do is to include some of the fields from the "Max Offices" CPT in this "Max Order" form so that they can then be included in the email notification that gets sent to the printer when a client submits an order through this form.

Is this possible??

*** In the Book Review example, it would be equivalent to showing Lisa's email address in the form once she had been selected as the reviewer. ***

Is there any documentation that you are following?
=========================================
I have been following the article on "CRED Forms for child content - the Book Review example.

Is there a similar example that we can see?

What is the link to your site?
hidden link --- but it is VERY much a development site at the moment

#602522

Dear Doug,

I assume you are going to display the parent "Max Offices" post information in the CRED form for creating child "Max Order" post.

You will need to follow our document to setup the CRED form for creating child "Max Order" post:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/
And display the link for creating child "Max Order" post:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/#displaying-the-form
It will pass the parent "Max Offices" post as an URL parameter to the target page, for example the parent post type "Max Offices" is using slug "max-offices", then the URL parameter name is "parent_max-offices_id"

Then you can get the parent post ID with shortcode :
[wpv-search-term param="parent_parent_max-offices_id"]
See our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term

With the parent post ID, you can display what you want, for example:
1) Create a content template "parent-max-offices-post-information", in this content template display the custom fields and other information.
2) In the CRED form for creating child "Max Order" post, display above content template, and specific the "id" attribute, for example:
[wpv-post-body view_template="parent-max-offices-post-information" id=[wpv-search-term param="parent_parent_max-offices_id"]]
More help:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

#602802

Many thanks, Lou Yang.

I am still working through these procedures, but I can see one more question coming up.

When I have completed the Max Orders form, I'll send an email notification to the printer so that he has all details of the order. I've worked out how to do that, but can see that I'll need to have a number of shortcodes to refer to the fields from the parent Max Office to include in the email.

Will they be something like: [types field='parent_max-offices_id_address-1'][/types] for the field "address-1"

Many thanks,

Doug
====

#602835

In the CRED email notification, the child post has already been saved into database, so you try these:
1) Create a content template "parent-max-offices-post-information-2", in this content template display the custom fields and other information.
2) In the CRED email notification, display above content template, and specific the "id" attribute,for example, if the parent post type "Max Offices" is using slug "max-offices",
[wpv-post-body view_template="parent-max-offices-post-information-2" id="$max-offices"]

More help:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
To include a field from the parent post, you would use the following shortcode:
[types field="xxxx" id="$yyyy"][/types]
Where xxxx is the field of the parent you want to show, and yyyy is the slug-name of the parent. The “$” is required, as this represents a variable where the parent post name will be replaced by the post ID, internally.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.