$sql = "SELECT ader.order_id FROM {$wpdb->posts} as post1
LEFT JOIN {$wpdb->term_relationships} ON post1.ID = {$wpdb->term_relationships}.object_id
LEFT JOIN {$wpdb->terms} ON {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->terms}.term_id
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as item_meta ON item_meta.meta_value = post1.ID
LEFT JOIN {$wpdb->prefix}woocommerce_order_items as ader ON ader.order_item_id = item_meta.order_item_id
LEFT JOIN {$wpdb->posts} as post2 ON ader.order_id = post2.ID
WHERE (wp_terms.slug='redq_rental' AND item_meta.meta_key = '_product_id' AND post2.post_status <> 'trash')";
$orders = $wpdb->get_results($sql, ARRAY_A);
1条答案
按热度按时间o7jaxewo1#
我做了一些研究,得到了以下问题。在这里,我检索了特定产品类型(定制产品类型“redq\u rental”)的所有订单。