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?
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"]
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
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.
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
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
Ok Luo, you already have the access to the website.
If you need I can share you all as private
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.
It works perfectly! My issue is resolved now. Thank you for your help, you are the best!