[Résolu] Cannot display WooCommerce orders in a relationship with a custom post type
This support ticket is created Il y a 3 années et 10 mois. 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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
Goal display WooCommerce orders that are in a relationship with a custom post type.
Issue: no orders are displayed when filtering on post relationship.
SETUP
CPT: Appointment
WooCommerce product: 'Some Product'
Post Form: 'Add an appointment' ==> Product to buy when submitting the form: 'Some Product'
Appointment and Order have a one-one relationship: appointment-order
CUSTOM CODE
When the Post Form is submitted the relationship is setup between the new Appointment and the Order:
This works: when I check Dashboard > Appointments > Appointment I see the relationship has been stored.
I can also setup the relationship from the dashboard via WooCommerce > Orders > 'My Order'.
I cannot setup the relationship from the dashboard via the CPT Dashboard > Appointment > 'My Appointment' as orders are not displayed in that relationship direction.
CUSTOM VIEW
I now want to setup a view displaying all Appointments and their RELATED orders.
SETUP 1
View 1: 'Display All Appointments'
Content Selection: 'Appointments'
Query Filter: 'Select posts with status of any.'
Loop item: [wpv-view name="appointment-order-details"]
View 2: 'Display Order Details' (slug: 'appointment-order-details')
Content Selection: 'Orders'
Query Filter: 'Select posts with status of any.'
Result:
- displays all Appointments
- for each of the appointments: displays all orders (so the same list of ALL orders is shown for each of the appointments in the loop)
SETUP 2
Goal: display only the orders in a relationship with the order in the loop !!!
View 1: 'Display All Appointments'
Content Selection: 'Appointments'
Query Filter: 'Select posts with status of any.'
Loop item: [wpv-view name="appointment-order-details"]
View 2: 'Display Order Details' (slug: 'appointment-order-details')
Content Selection: 'Orders'
Query Filter: 'Select posts with status of any.'
Query Filter: 'Filter by post relationship or repeatable fields group owner'
'Select posts in a Appointments Orders relationship that are a related to the current post in the loop.' !!!
Result:
- displays all Appointments
- displays NO ORDERS !!!
Hello. Thank you for contacting the Toolset support.
It should display the related order details. It seems you have correct setup but let me first review your current setup once you pass the access details to me and then I required I will try to setup a same setup with my test site to know whats going wrong here. It seems to me the relationship here but let me first check.
Can you please share problem URL where you added the working view where it displays the order details as well as the problem URL where you added the view where its not showing the order details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I'm not sure whats going on but to get the related order ID, i've to add the following shortcode to "Custom Code" section offered by Toolset within the code snippet "get-related-app-order":
=> lien caché