Download all invoices

WCMp Core

Resolved
Viewing 41 reply threads
  • Author
    Posts
    • #133989
      MaxenceTP
      Participant

      Hello,
      How can I download an archive with all the invoices for my site? With WCMp PDF Invoice
      I have tens of thousands of orders and hundreds of pages, even downloading them 100 by 100 would take too long.

    • #134006

      Hi, thanks for getting in touch with us.
      The default flow is such that admin can download either from Woocommerce order page or by clicking the individual order and vendor can download the pdf invoice from order section.
      However if you are looking for some different flow you need to do custom code on your end.

    • #134019
      MaxenceTP
      Participant

      No, I don’t want to change that. I just want to download all the invoices, and not do the orders one by one or page by page

    • #134054

      In order to download pdf invoice in bulk go to vendor dashboard>orders. Over there select the pdf for the order you want to download and choose download pdf from bulk options.
      Here is the video- https://www.loom.com/share/5143706c86fd40bf93d4a7c99381e815

    • #134103
      MaxenceTP
      Participant

      Yes, I know that. But with 100 orders per page, I still have 300 pages and it’s impossible for me to do all the pages.
      Is there a way to create a small script in PHP that would allow me to do this with the WCMp functions for all the orders?

      That I can have one archive with all the PDF files in it

    • #134132

      Let me consult with the develop, where we have any such hook/filter, that you can use to create the custom code.

    • #134139
      MaxenceTP
      Participant

      Okay, keep me informed

    • #134145

      Hi,
      As per your requirement, you have to add custom code on you end using below filter.

      apply_filters( 'wcmp_vendor_orders_bulk_action_ids', isset($filterActionData['selected_orders']) ? $filterActionData['selected_orders'] : array(), $filterActionData, $requestData );
      Copy

      Regards

    • #134150
      MaxenceTP
      Participant

      Thank you, but I don’t really understand how to put all the orders into this ?

    • #134189
      This reply has been marked as private.
    • #134327
      MaxenceTP
      Participant

      Can you publish the changes as an update when they are working?
      These changes have not been integrated: https://multivendorx.com/support-forum/topic/pdf-template-common-to-all-vendors/#post-128946
      I’m losing the changes with every update, it’s quite annoying

    • #134328
      MaxenceTP
      Participant

      I tested with your plugin but I don’t understand when the filter is executed. I tried to debug the variable to see its content but the code is never executed. Can you test with this on your side too? There are supposed to be logs in the wordpress debug.log file:

      Copy

      `add_filter(‘wcmp_vendor_orders_pdf_download_ids’,’test_function_wcmp’);
      function test_function_wcmp($selected_orders) {
      error_log(“DEBUG IN debug.log”);
      error_log(print_r($selected_orders, true));
      return $newArray;

      Copy

      `

      Can you tell me more?

    • #134336

      Hi,
      This filter will trigger when you select Download PDF Invoice from dropdown and then press the Download PDF button.

      Checkout the image – https://prnt.sc/26tr2q3

      you have to add all vendor orders id to download those PDF

      Regards,

    • #134338
      MaxenceTP
      Participant

      Oohh right, I wasn’t thinking about that.
      Is it possible to do that on the wp-admin panel?

      And do you know if it is possible to add a button that calls your function to generate the PDF?

    • #134369

      Hi,
      WCMp PDF invoice Added the function to download the pdf from admin panel using below filter –

      add_filter('handle_bulk_actions-edit-shop_order', array($this, 'pdf_invoice_packing_slip_bulk_action_handler'), 10, 3);
      Copy

      So to change the default flow you have to add custom code using below filter.
      You have to remover filter end add this filter with your custom function. It need good amount of custom code.

      For your second point you have to add custom code. The function only called when the download pdf button is clicked and dropdown selected.

      Regards,

    • #134383
      MaxenceTP
      Participant

      I didn’t really understand how to remove and add the filter. I tested this :

      remove_filter( 'handle_bulk_actions-edit-shop_order', 'pdf_invoice_packing_slip_bulk_action_handler', 10 );
      
      add_filter( 'handle_bulk_actions-edit-shop_order', 'max_tesssste', 20 , 3 );
      function max_tesssste($redirect_to, $doaction, $order_ids) {
          error_log("DEBUG IN debug.log");
          error_log(print_r($order_ids, true));
      }
      Copy

      My function is executed but the plugin function is executed too, so it is executed twice. Can you give me more information?

    • #134415

      Hi,
      To remove the filter use below code –

      add_action('admin_init', 'custom_changes_wcmp_pdf_invoice');
      function custom_changes_wcmp_pdf_invoice(){
          global $WCMp_PDF_Invoices;
          remove_filter('handle_bulk_actions-edit-shop_order', array($WCMp_PDF_Invoices->admin, 'pdf_invoice_packing_slip_bulk_action_handler'), 10, 3);
      }
      Copy

      Regards,

    • #134442
      MaxenceTP
      Participant

      Thanks, it works 🙂
      I took the code from the “pdf_invoice_packing_slip_bulk_action_handler” function so I can modify it as I want, but I don’t understand how to define “$this->pdf_actions” in this code?

      add_filter( 'handle_bulk_actions-edit-shop_order', 'max_tesssste', 10 , 3 );
      function max_tesssste($redirect_to, $doaction, $order_ids) {
          global $WCMp_PDF_Invoices;
      
          if (!array_key_exists($doaction, $this->pdf_actions)){ // <------------- HERE
              return $redirect_to;
          }
          if (empty($order_ids)) { 
              return $redirect_to;
          }
              
          $general_settings = get_wcmp_pdf_invoices_settings();
          $args = array(
              'order_ids' => $order_ids, 
              'user_id' => get_current_user_id(), 
              'user_type' => 'admin',
              'settings' => $general_settings
          );
          $html = $WCMp_PDF_Invoices->utils->get_html($doaction, $args);
          
          if ($html) {
              $pdf_maker = get_wcmp_pdf_invoices_pdfmaker( $html, $general_settings );
              $pdf = $pdf_maker->output();
              wcmp_pdf_invoices_pdf_headers( $doaction.'.pdf', $general_settings['pdf_output'], $pdf );
              echo $pdf;
              die();
          }
          exit;
      }
      Copy
    • #134443

      We pass these variables via $this
      So you need to pass a new variable along with new variable content. For reference check class-wcmp-pdf-invoices-admin.php

    • #134648
      MaxenceTP
      Participant

      Thank you 🙂

      I have another question, I use this code to get all orders_ids:

      $query = new WC_Order_Query( array(
          'orderby' => 'date',
          'order' => 'DESC',
          'return' => 'ids',
          'status' => array('wc-completed', 'wc-processing'),
          'date_paid' => '2018-01-01...2022-12-31',
          'vendor' => '??',
      ) );
      $order_ids = $query->get_orders();
      Copy

      But how to retrieve only orders from a specific vendor?

    • #134649
      MaxenceTP
      Participant

      I have another question regarding WCMp Core, I have orders that were placed several years ago before the suborders system was implemented.
      I have orders that were placed years ago before the suborder system was implemented, so the vendors don’t have access to these very old orders, how do I generate the suborders for the orders that don’t have them?

    • #134681

      Hi,
      using below code you can get all vendor order

      $user_id = get_current_vendor_id();
      
      Copy

      then use

      'author' => $user_id,
      Copy

      Regards

    • #134704

      @MaxenceTP, when we released the split order module, we had our migration cron that will convert all the old orders into suborders. You can rerun this cron via WCMp >> Settings >> Tools and click on “Force WCMp order migrate” : https://prnt.sc/4M8uFzroTIsY

      • #135135
        MaxenceTP
        Participant
        This reply has been marked as private.
      • #135136
        MaxenceTP
        Participant
        This reply has been marked as private.
      • #135133
        MaxenceTP
        Participant
        This reply has been marked as private.
      • #135134
        MaxenceTP
        Participant
        This reply has been marked as private.
    • #135137
      MaxenceTP
      Participant
      This reply has been marked as private.
    • #135170
      This reply has been marked as private.
      • #135280
        MaxenceTP
        Participant

        It was obviously orders that were deleted but the commissions were not deleted with them.
        So I deleted them manually and started the migration again. No change, the sub-orders are still not created.

        The link to the video does not work either.

        Can you please look again?

    • #135294

      Maxence you need to follow this video https://watch.screencastify.com/v/uSGP7NCNLUO3k7FcM9f9
      I checked the video, it is working fine.

      Anyway, here is also a screenshot of the setting that you need to follow, goto mail order details and click on “generate suborder” : https://prnt.sc/_RrWc3MdGJ46

      • #135301
        MaxenceTP
        Participant

        It does indeed work like this. However I have several hundred orders that have no suborders on my production site, it’s just impossible to do them all one by one.
        How can I do several at once? Or all at the same time?

    • #135307
      MaxenceTP
      Participant

      The solution of putting all the orders_id works but has its limits, I can’t upload more than 250 orders in a PDF without the site crashing.
      I would have to do this 120 times to download 250 invoices at a time, which is still too long.
      What other solution can you suggest?

    • #135364

      @MaxenceTP, let me consult this with my team, where you can generate Sub order using bulk edit.

    • #135403
      MaxenceTP
      Participant

      Ok, keep me informed

    • #135419

      Hi,

      To add this functionality to bulk action you have to add custom code
      Using below code, you can add custom mane and add some function as per your requirement.

      // Add a bulk action to Orders bulk actions dropdown
      add_filter( 'bulk_actions-edit-shop_order', 'decrease_meals_orders_bulk_actions' );
      function decrease_meals_orders_bulk_actions( $bulk_actions ) {
          $bulk_actions['custom_id'] = 'custom text';
          return $bulk_actions;
      }
      
      // Process the bulk action from selected orders
      add_filter( 'handle_bulk_actions-edit-shop_order', 'decrease_meals_bulk_action_edit_shop_order', 10, 3 );
      function decrease_meals_bulk_action_edit_shop_order( $redirect_to, $action, $post_ids ) {
          if ( $action === 'custom_id' ){
              $processed_ids = array(); // Initializing
      
              foreach ( $post_ids as $post_id ) {
                  //your custom code
              }
          }
          return $redirect_to;
      }
      Copy

      Then you have to add custom code.

      As a reference kindly check below file after line no 549
      https://github.com/wcmarketplace/dc-woocommerce-multi-vendor/blob/master/classes/class-wcmp-admin.php

      Regards,

    • #135421
      MaxenceTP
      Participant

      What is the code to put to generate the suborders if they don’t already exist ?

    • #135498

      @MaxenceTP, I am afraid we don’t have any ready-made code for this. so you have to follow the code shared here (https://github.com/wcmarketplace/dc-woocommerce-multi-vendor/blob/master/classes/class-wcmp-admin.php), apply the same via the custom code.

    • #135562
      MaxenceTP
      Participant

      In the code in your answer #135419, $posts_id is the list of selected orders?

      I just need to put lines 607 and 608 in “Your custom code”, right?

      But wouldn’t it be easier to fix the “Force WCMp order migrate” button bug? https://prnt.sc/4M8uFzroTIsY

    • #135631

      Hi,
      We will check this on our end, If possible then will add this functionality in our next update.

      Regards,

    • #135632
      MaxenceTP
      Participant

      Ok, I’m waiting for it :/

    • #135718

      We have added this feature. Kindly check.

    • #135780
      MaxenceTP
      Participant

      Thank you it’s working 🙂
      But by the way the “Tool” button still do nothing

    • #136150

      @MaxenceTP, we will check with the team.

    • #137003
      MaxenceTP
      Participant

      Has the patch been released or not yet?

    • #140685
      MaxenceTP
      Participant

      Is it possible to export as an admin all the orders of all vendors in a CSV file ?

    • #140877

      @MaxenceTP, Currently this feature is not supported.
      However, you can definitely use woocommerce hook and create this module for your site. If you need a reference of hook/filter, let us know.
      Please note this module requires huge amount of coding.

    • #141857
      MaxenceTP
      Participant

      I would appreciate some instruction on how to do this please 🙂

Viewing 41 reply threads

The topic ‘Download all invoices’ is closed to new replies.