[Resuelto] Retreive relationship between order / product and CRED commerce postype
This support ticket is created hace 6 años, 6 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
I have created a Cred commerce form.
This Cred is creating a postype (concours) that contains different custom fields and is linked to a WC product (inscription).
Now, I would like to retrieve the postype ID that have been created by the Cred, meaning, the relationship between the order ID and the postype ID.
I'm not sure when exactly in the process you need to connect the order ID and the post ID for the custom post created by the CRED form, or what you want to use it for exactly.
It may be that one of the other hooks could serve you. From the documentation it is not clear that another has both the order ID and post ID available, but if you dump the complete available parameters to your debug log to inspect them you may find another hook may also serve the purpose.
What I want to do, is to add custom fields to WC emails using hook or child mail template.
So, that's why I need to retrieve the post_id of the created postype. Then, with this ID, i will be able to retrieve all postmeta I need.
I will try your cred_commerce_after_order_completed hook and see if this is sufficient to get all needed data.
OK, it sounds like you will need to use one of the CRED Commerce hooks to identify the post ID that links to the order ID and you will need to store that post ID as a field of the order so that you can later access it and identify the matching post.
I hope you can find the hook that works for you to do that, but let me know.