• Resolved Nitrat

    (@nitrat)


    Hi Ewout
    I make a Mysql query request to Woocommerce orders –

    SELECT posts.ID as order_id, posts.post_date
           ,(select oim.meta_value  from wp_woocommerce_order_itemmeta as oim
             where oim.order_item_id = woi.order_item_id
    		and oim.meta_key = '_wcpdf_formatted_invoice_number' ) as number
    		
           (select count(1) from wp_woocommerce_order_itemmeta as woim
             where woim.order_item_id = woi.order_item_id) as count_el
           FROM wp_posts as posts,
                wp_woocommerce_order_items as woi
          where  woi.order_id = posts.ID
           and   posts.post_type = 'shop_order'
           and posts.post_status = 'wc-on-hold'
    

    But this query displays null value

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    This is quite an advanced SQL query _wcpdf_formatted_invoice_number resides in wp_postmeta is all I can say. It looks like you’re trying to get it from itemmeta, but it’s better to consult a MySQL expert about this ??

    Thread Starter Nitrat

    (@nitrat)

    Thanks for the tip! The answer’s out here somewhere..but where???

    SELECT posts.ID as order_id, posts.post_date
           ,(select ww.meta_value  from wp_postmeta as ww
             where ww.post_id = wp_posts.ID
    		and ww.meta_key = '_wcpdf_formatted_invoice_number' ) as nomer
     ,(select count(1) from wp_woocommerce_order_itemmeta as woim
             where woim.order_item_id = woi.order_item_id) as count_el
           FROM wp_posts as posts,
                wp_woocommerce_order_items as woi
          where  woi.order_id = posts.ID
           and   posts.post_type = 'shop_order'
           and posts.post_status = 'wc-on-hold'
    Thread Starter Nitrat

    (@nitrat)

    Eureka!

    SELECT posts.ID as order_id, posts.post_date
           ,(select ww.meta_value  from wp_postmeta as ww
             where posts.ID = ww.post_id
    		and ww.meta_key = '_wcpdf_formatted_invoice_number' ) as number
    ,(select count(1) from wp_woocommerce_order_itemmeta as woim
             where woim.order_item_id = woi.order_item_id) as count_el
           FROM wp_posts as posts,
                wp_woocommerce_order_items as woi
          where  woi.order_id = posts.ID
           and   posts.post_type = 'shop_order'
           and posts.post_status = 'wc-on-hold'
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to acess to _wcpdf_formatted_invoice_number?’ is closed to new replies.