dqj29136 2018-11-20 16:38
浏览 24

WooCommerce股票报告 - 添加“按产品过滤”功能

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 对于这个复杂问题的解释说明
    • ¥50 三种调度算法报错 采用的你的方案
    • ¥15 关于#python#的问题,请各位专家解答!
    • ¥200 询问:python实现大地主题正反算的程序设计,有偿
    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败