Skip Navigation

[Resolved] Creating relationship between post type and woocommerce order

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 1 reply, has 2 voices.

Last updated by Luo Yang 1 year, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2465345

Tell us what you are trying to do?
I need a many-to-many relationship between a custom post type "PartyBox" and a Woocommerce order placed on the session. I have already created the relationship.

Users enter the site via a QR Code on the PartyBox content template. I can grab the Id of the PartyBox (post type) at that time as it needs to be used for creating the relationship with the Woocommerce order. The id of the woocommerce order isn't available until after the order has been created. I'm using woocommerce_order_status_completed hook and then attempting to create the relationship with toolset_connect_posts( 'partybox-order', $box_id, $order_id );.

How can I get the PartyBox post type id to use when order is created? Have tried global variables and cookies and still having issues getting the box_id at the time the order is created. Thank you for your assistance.

Is there any documentation that you are following? Many posts

Is there a similar example that we can see? No

What is the link to your site? On development server only

#2465525

Hello,

Since it is many-to-many relationship, you can try relationship API function: toolset_get_related_posts()
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Use the Woocommerce order ID to get related "PartyBox" post IDs.

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