Skip Navigation

[Gelöst] How to add a post reference field to the WooCommerce Cart

This support ticket is created vor 4 Jahren, 9 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Anthony vor 4 Jahren, 9 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1531337

I am modifying the WooCommerce Product CTP with a custom field group that includes a post reference field to another (Toolset) CPT called 'Artist'. I have the post-title-with-a-link from the 'Artist' CPT displaying on the customized single product page - so far, so good. Now I want to also display it on the cart page under the product title.

I'm using the 'Edit WooCommerce Templates' plugin (very handy!) to manage modifying WooCommerce templates, and I know where in the WooCommerce cart.php template the desired modification needs to go, but I can't figure out what code will retrieve the post-title-with-a-link of the Artist post reference for the product post in the cart.

#1531703

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Normally, this is how you can display the post-reference field on a single post content template or post body or withing views.
=> https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/#displaying-fields-that-belong-to-the-related-post

As you already know, Toolset do not offer to edit the WooCommerce templates.

So, basically - you can display the post reference field value using the following shortcode:

 [wpv-post-link item="@post-reference-field-slug.parent"]

Where:
- You can replace the post-reference-field-slug with your original pst reference field slug.

#1536279

My issue is resolved now. Thank you!