| @@ 78-88 (lines=11) @@ | ||
| 75 | ||
| 76 | $top_sellers = array(); |
|
| 77 | ||
| 78 | foreach ( $report_data as $item ) { |
|
| 79 | $product = wc_get_product( $item->product_id ); |
|
| 80 | ||
| 81 | if ( $product ) { |
|
| 82 | $top_sellers[] = array( |
|
| 83 | 'name' => $product->get_title(), |
|
| 84 | 'product_id' => (int) $item->product_id, |
|
| 85 | 'quantity' => wc_stock_amount( $item->order_item_qty ), |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| 90 | $data = array(); |
|
| 91 | foreach ( $top_sellers as $top_seller ) { |
|
| @@ 291-301 (lines=11) @@ | ||
| 288 | ) ); |
|
| 289 | ||
| 290 | $top_sellers_data = array(); |
|
| 291 | foreach ( $top_sellers as $top_seller ) { |
|
| 292 | $product = wc_get_product( $top_seller->product_id ); |
|
| 293 | ||
| 294 | if ( $product ) { |
|
| 295 | $top_sellers_data[] = array( |
|
| 296 | 'title' => $product->get_title(), |
|
| 297 | 'product_id' => $top_seller->product_id, |
|
| 298 | 'quantity' => $top_seller->order_item_qty, |
|
| 299 | ); |
|
| 300 | } |
|
| 301 | } |
|
| 302 | $top_sellers_data = apply_filters( 'woocommerce_cli_top_sellers_report', $top_sellers_data ); |
|
| 303 | ||
| 304 | $formatter = $this->get_formatter( $assoc_args ); |
|