You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since shop_order use different status, the standard post_status is not used, but instead:
'wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-cancelled', 'wc-refunded' and 'wc-failed'.
The first thing i noticed is that my connection "shop_order_to_warehouse" (warehouse is a cpt) in admin order single page. Does not show my selected warehouse (but i can't select another one since i use a many-to-one cardinality.
SELECT wp_posts.*,
wp_p2p.*
FROM wp_posts
INNER JOIN wp_p2p
where 1=1
AND wp_posts.post_type = 'warehouse'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'aw-disabled'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
AND (
wp_p2p.p2p_type = 'shop_order_to_warehouse'
AND wp_posts.id = wp_p2p.p2p_to
AND wp_p2p.p2p_from IN
(
SELECT wp_posts.id
FROM wp_posts
WHERE 1=1
AND wp_posts.id IN (9705)
AND wp_posts.post_type = 'shop_order'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'aw-disabled'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
ORDER BY wp_posts.post_date DESC ))
ORDER BY wp_posts.post_date DESC
I tried passing the wc status in the connected WP_Query
SELECT wp_posts.*,
wp_p2p.*
FROM wp_posts
INNER JOIN wp_p2p
where 1=1
AND wp_posts.post_type = 'warehouse'
AND ((
wp_posts.post_status = 'wc-pending'
OR wp_posts.post_status = 'wc-processing'
OR wp_posts.post_status = 'wc-on-hold'
OR wp_posts.post_status = 'wc-completed'
OR wp_posts.post_status = 'wc-cancelled'
OR wp_posts.post_status = 'wc-refunded'
OR wp_posts.post_status = 'wc-failed'))
AND (
wp_p2p.p2p_type = 'shop_order_to_warehouse'
AND wp_posts.id = wp_p2p.p2p_to
AND wp_p2p.p2p_from IN
(
SELECT wp_posts.id
FROM wp_posts
WHERE 1=1
AND wp_posts.id IN (9705)
AND wp_posts.post_type = 'shop_order'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'aw-disabled'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
ORDER BY wp_posts.post_date DESC ))
ORDER BY wp_posts.post_date DESC
As we can see it does not use the correct post_status since shop_order use different status.
The correct SQL (tested) should be :
SELECT wp_posts.*,
wp_p2p.*
FROM wp_posts
INNER JOIN wp_p2p
where 1=1
AND wp_posts.post_type = 'warehouse'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'aw-disabled'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
AND (
wp_p2p.p2p_type = 'shop_order_to_warehouse'
AND wp_posts.id = wp_p2p.p2p_to
AND wp_p2p.p2p_from IN
(
SELECT wp_posts.id
FROM wp_posts
WHERE 1=1
AND wp_posts.id IN (9705)
AND wp_posts.post_type = 'shop_order'
AND (
wp_posts.post_status = 'wc-pending'
OR wp_posts.post_status = 'wc-processing'
OR wp_posts.post_status = 'wc-on-hold'
OR wp_posts.post_status = 'wc-completed'
OR wp_posts.post_status = 'wc-cancelled'
OR wp_posts.post_status = 'wc-refunded'
OR wp_posts.post_status = 'wc-failed')
ORDER BY wp_posts.post_date DESC ))
ORDER BY wp_posts.post_date DESC
The text was updated successfully, but these errors were encountered:
Hi,
Since shop_order use different status, the standard post_status is not used, but instead:
'wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-cancelled', 'wc-refunded' and 'wc-failed'.
The first thing i noticed is that my connection "shop_order_to_warehouse" (warehouse is a cpt) in admin order single page. Does not show my selected warehouse (but i can't select another one since i use a many-to-one cardinality.
Screenshot
Here my connection:
So the second thingi noticed is that i query the connected cpt in admin orders list to add some extra data in the order table.
I managed to have the correct object from get_queried_object() but $connected is empty.
Generated SQL:
I tried passing the wc status in the connected WP_Query
Generated SQL:
As we can see it does not use the correct post_status since shop_order use different status.
The correct SQL (tested) should be :
The text was updated successfully, but these errors were encountered: