WooCommerce Stock Reports - Add “Filter by Product” functionality












0














I am currently contemplating how to filter/search WooCommerce stock reports by product. I was thinking of adding an input box, like so:



enter image description here



and use it to reduce the number of Products shown in the list below.



Ideally, I'd like to use Javascript in order to make the filtering user-friendly. Using the WooCommerce API to create a whole new report page seems like overkill for such a small matter. So I thought, if I just made WooCommerce output all products in its stock reports, I could grab them afterwards and filter them with JS. That is where I am stuck since WooCommerce creates the report pages inside the WC_Report_Stock class. To be exact, it's preparing the output in the prepare_items method and sets the number of pages displayed to 20:



public function prepare_items() {

$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
$current_page = absint( $this->get_pagenum() );
$per_page = apply_filters( 'woocommerce_admin_stock_report_products_per_page', 20 );

$this->get_items( $current_page, $per_page );

/**
* Pagination.
*/
$this->set_pagination_args( array(
'total_items' => $this->max_items,
'per_page' => $per_page,
'total_pages' => ceil( $this->max_items / $per_page ),
) );
}


Since I don't want to change the Plugin Code, I am unsure of how to proceed and would hope for someone to point me in the right direction.










share|improve this question



























    0














    I am currently contemplating how to filter/search WooCommerce stock reports by product. I was thinking of adding an input box, like so:



    enter image description here



    and use it to reduce the number of Products shown in the list below.



    Ideally, I'd like to use Javascript in order to make the filtering user-friendly. Using the WooCommerce API to create a whole new report page seems like overkill for such a small matter. So I thought, if I just made WooCommerce output all products in its stock reports, I could grab them afterwards and filter them with JS. That is where I am stuck since WooCommerce creates the report pages inside the WC_Report_Stock class. To be exact, it's preparing the output in the prepare_items method and sets the number of pages displayed to 20:



    public function prepare_items() {

    $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
    $current_page = absint( $this->get_pagenum() );
    $per_page = apply_filters( 'woocommerce_admin_stock_report_products_per_page', 20 );

    $this->get_items( $current_page, $per_page );

    /**
    * Pagination.
    */
    $this->set_pagination_args( array(
    'total_items' => $this->max_items,
    'per_page' => $per_page,
    'total_pages' => ceil( $this->max_items / $per_page ),
    ) );
    }


    Since I don't want to change the Plugin Code, I am unsure of how to proceed and would hope for someone to point me in the right direction.










    share|improve this question

























      0












      0








      0







      I am currently contemplating how to filter/search WooCommerce stock reports by product. I was thinking of adding an input box, like so:



      enter image description here



      and use it to reduce the number of Products shown in the list below.



      Ideally, I'd like to use Javascript in order to make the filtering user-friendly. Using the WooCommerce API to create a whole new report page seems like overkill for such a small matter. So I thought, if I just made WooCommerce output all products in its stock reports, I could grab them afterwards and filter them with JS. That is where I am stuck since WooCommerce creates the report pages inside the WC_Report_Stock class. To be exact, it's preparing the output in the prepare_items method and sets the number of pages displayed to 20:



      public function prepare_items() {

      $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
      $current_page = absint( $this->get_pagenum() );
      $per_page = apply_filters( 'woocommerce_admin_stock_report_products_per_page', 20 );

      $this->get_items( $current_page, $per_page );

      /**
      * Pagination.
      */
      $this->set_pagination_args( array(
      'total_items' => $this->max_items,
      'per_page' => $per_page,
      'total_pages' => ceil( $this->max_items / $per_page ),
      ) );
      }


      Since I don't want to change the Plugin Code, I am unsure of how to proceed and would hope for someone to point me in the right direction.










      share|improve this question













      I am currently contemplating how to filter/search WooCommerce stock reports by product. I was thinking of adding an input box, like so:



      enter image description here



      and use it to reduce the number of Products shown in the list below.



      Ideally, I'd like to use Javascript in order to make the filtering user-friendly. Using the WooCommerce API to create a whole new report page seems like overkill for such a small matter. So I thought, if I just made WooCommerce output all products in its stock reports, I could grab them afterwards and filter them with JS. That is where I am stuck since WooCommerce creates the report pages inside the WC_Report_Stock class. To be exact, it's preparing the output in the prepare_items method and sets the number of pages displayed to 20:



      public function prepare_items() {

      $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
      $current_page = absint( $this->get_pagenum() );
      $per_page = apply_filters( 'woocommerce_admin_stock_report_products_per_page', 20 );

      $this->get_items( $current_page, $per_page );

      /**
      * Pagination.
      */
      $this->set_pagination_args( array(
      'total_items' => $this->max_items,
      'per_page' => $per_page,
      'total_pages' => ceil( $this->max_items / $per_page ),
      ) );
      }


      Since I don't want to change the Plugin Code, I am unsure of how to proceed and would hope for someone to point me in the right direction.







      javascript php wordpress woocommerce






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 16:38









      j4g0

      267




      267





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397553%2fwoocommerce-stock-reports-add-filter-by-product-functionality%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397553%2fwoocommerce-stock-reports-add-filter-by-product-functionality%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin