• Resolved brahmbhattsnehal

    (@snehaladdweb)


    Hi There,

    Is any way through which we can sort the invoice number in descending order and the orders which has no invoice number [ i.e. Invoice is not yet generated ] will be displayed at last?

    I already gone through the solution you provided for one of the support request

    i.e.

    add_filter( ‘wpo_wcpdf_invoice_number_column_orderby’, function(){ return ‘meta_value_num’; } );

    But it doesn’t work for the BLANK Invoice Number. Meaning It will not show orders in the last which does not have any invoice generated yet.

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @snehaladdweb

    Unfortunately we are bound by the limitations of WordPress queries here, and it seems that sorting will remove the orders that have empty Invoice numbers. I’m afraid we can’t help much more on this due to that.

    Thread Starter brahmbhattsnehal

    (@snehaladdweb)

    Hi @alexmigf

    Thanks for your prompt response. I appriate that

    I understand that we’ve a limitation of WordPress queries here. Any other workaround which you suggest to meet the requrirement?

    Thanks & regards,
    Snehal Brahmbhatt

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @snehaladdweb,

    You can try this code snippet, but as my colleague @alexmigf said, it hides the orders without an invoice:

    add_action( 'parse_query', 'wpo_wcpdf_set_orderby_pdf_invoice_number_in_admin' );
    function wpo_wcpdf_set_orderby_pdf_invoice_number_in_admin( $query ){
    	if( is_admin() && $_GET['post_type'] === 'shop_order' ){
    		if(!isset($_GET['orderby'])) $_GET['orderby'] = 'pdf_invoice_number'; // Invoice Number column
    		if(!isset($_GET['order'])) $_GET['order'] = 'desc'; //You can change it to ASC
    	}
    }

    If you decide to use this code snippet, you’ll need to click on the Orders column heading to change the sort, in order to see the hidden orders (those without an invoice yet).

    Hope it helps.

    Thread Starter brahmbhattsnehal

    (@snehaladdweb)

    Hi @yordansoares

    Thanks for your reply but this will not sort as per my requirement. I would like to see all orders which has no invoice will be last.

    Also, It is not sorting the invoice number in proper ASC/DESC format.

    You can try with below Invoice Number(s)
    – 10009
    – 1001
    – 10010

    It will show you in the same order which I mentioned above for the ASC.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sort by invoice number desc’ is closed to new replies.