Skip Navigation

[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.

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)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par Minesh Il y a 3 années et 10 mois.

Assisté par: Minesh.

Auteur
Publications
#1913477
Order-Connected-to-an-Appointment0.jpg
Test-Display-All-Appointments0.jpg
Display-Appointment-Order-Details0.jpg
Result-Setup-10.jpg
Result-Setup-20.jpg

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:

toolset_connect_posts( 'appointment-order', $cred_post_id, $order_id );

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 !!!

#1913999

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

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.

#1921629

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

What if you share a duplicator copy of your site - that will help to to setup your site easily and save the time.

More info:
https://toolset.com/faq/provide-supporters-copy-site/

If you woant prefer duplicator, then I will go with the zips you shared to setup that manually.

I have set the next reply to private which means only you and I have access to it.

#1928191

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

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é

add_shortcode( 'get-app-order', 'func_get_app_order' );
function func_get_app_order( $atts ) {
    return toolset_get_related_post($atts['app_id'],'appointment-order-relationship','child');
}

Then within the following view, I've called the above shortcode as:
=> lien caché

<td> [wpv-view name="appointment-order-relationship-test" ids="[get-app-order app_id='[wpv-post-id]']"]</td>

And to the view that displays the order - I've added the following filter:
=> lien caché

  Bericht-ID filter
Alleen berichten omvattenmet ID's ingesteld door het View shortcode attribuut "ids" bijv. [wpv-view name="view-name" ids="1"]

You can activate the WooCommerce hidden fields from:
=> Toolset => Settings => Front-end Content Tab => Hidden Custom fields.

Please check, I've activated most of the billing fields - you can activate fields as required from this section:
- lien caché

Later, you can display the fields as within your view's loop editor.

Order price: [wpv-post-field name="_order_total"]