get woocommerce product image url and price from database [closed]

The only way I see is to use nested WHERE clause: SELECT p.*, pm2.meta_value as image_file FROM ( SELECT p.ID, p.post_title, `post_content`, `post_excerpt`, t.name AS product_category, t.term_id AS product_id, t.slug AS product_slug, tt.term_taxonomy_id AS tt_term_taxonomia, tr.term_taxonomy_id AS tr_term_taxonomia, MAX(CASE WHEN pm1.meta_key = ‘_price’ then pm1.meta_value ELSE NULL END) as price, MAX(CASE WHEN pm1.meta_key = ‘_sku’ … Read more

Get orders of a specific customer woocommerce

Try using wordpress get_posts() instead $user_id = 22; $orders = get_posts( array( ‘meta_key’ => ‘_customer_user’, ‘meta_value’ => $user_id, ‘post_type’ => ‘shop_order’, ‘post_status’ => array_keys( wc_get_order_statuses() ), ‘numberposts’ => -1 )); echo ‘<pre>’; print_r( $orders ); echo ‘</pre>’;