[Resolved] Display the post title

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.

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

Problem:

Display related post information in Woocommerce cart page.

Solution:

It needs custom codes, see details here:

https://toolset.com/forums/topic/display-the-post-title/#post-1134818

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

This topic contains 8 replies, has 2 voices.

Last updated by domenicoS 1 month, 3 weeks ago.

Assigned support staff: Luo Yang.

Author
Posts
#1134136

Hi,

I've created a great booking system with toolset.
A last task is to catch the title of a parent post and display it in the cart

I displayed it in the post with this string:

[wpv-post-title item="@preventivo-struttura.parent"] 

Then I click on the button And I go to the cart

In the I cart I displeyed all the post meta of the child post, but I need to display also the title of the parent post.

How can I do?

#1134148

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi,

I assume we are talking about similar problem as your another thread:
https://toolset.com/forums/topic/how-is-possible-to-save-it-in-the-woocommerce-order-meta/

1) There isn't such kind of built-in feature, it needs custom codes, see above thread.

2) In my opinion, you can setup a similar Toolset post form, display post title as the submit button text, for example:
[cred_field field="form_submit" output="bootstrap" value="[wpv-post-title]" class="btn btn-primary btn-lg"]

#1134168

Hi Luo, yes similar but about another meta.

I display all the meta correctly in the cart meta.
Tha only one I'm not able to display is the title of the post.

If you remeber I've a cutom post type "accommodation" with a form

The form create the new pot type "quote"

This to are linked with a relationship

In the cart i'm able to diplay al the meta of "quote post type" but not the meta of "accommodation post type"

I tryed with tihis code

		$accommodation_name =  get_the_title( $post->post_parent);

But is dispalyed the title of "quote" post and not the title of "accommodation" post

If you want I can share with you the link

#1134177

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

You can get the "quote" post ID, for example:

$post_id = $cart_item['cred_meta']['cred_post_id'];

With the "quote" post ID, you can get the related "accommodation" post ID with API function toolset_get_related_post():
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

With the "accommodation" post ID, you can get it's post title:
https://developer.wordpress.org/reference/functions/get_the_title/

For your reference.

#1134180

It is already set in this way:

$post_id = $cart_item['cred_meta']['cred_post_id'];
$accommodation_name =  get_the_title( $post_id->post_parent);

But it give the title of the actual page and not of the accommodation page

#1134183

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

As I mentioned above, you will need to use function toolset_get_related_post() to get related "accommodation" post ID.
https://toolset.com/forums/topic/display-the-post-title/#post-1134177

If you still need more assistance for it, please provide a test site with the same problem, and point out the problem page URL and form URL, where I can edit your PHP codes, I need a live website to test and debug, and I am off now, will check it tomorrow morning. thanks

#1134193

Ok Luo, you already have the access to the website.
If you need I can share you all as private

#1134818

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I can get the your website credentials in this post:
https://toolset.com/forums/topic/how-is-possible-to-save-it-in-the-woocommerce-order-meta/#post-1116205

Since you did not point out the problem page URL and form URL, I assume we are talking about this post type relationship "preventivo-struttura":
hidden link

Here is an example:

$post_id = $cart_item['cred_meta']['cred_post_id'];
$accommodation_id = toolset_get_related_post( $post_id, 'preventivo-struttura',  'parent');
$accommodation_title = get_the_title( $accommodation_id );

"preventivo-struttura" is the post type relationship slug, see our document:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

For your reference.

#1134923

It works perfectly! My issue is resolved now. Thank you for your help, you are the best!