Esempio n. 1
0
 /**
  *
  *
  * @return unknown
  */
 public function download_csv()
 {
     if (!$this->orders) {
         return false;
     }
     extract(PV_Orders::format_order_details($this->orders, $this->product_id));
     $headers = PV_Orders::get_headers();
     // Export the CSV
     require_once pv_plugin_dir . 'classes/front/orders/class-export-csv.php';
     PV_Export_CSV::output_csv($this->product_id, $headers, $body, $items);
 }
Esempio n. 2
0
 /**
  * Sort the data for CSV output first
  *
  * @param int   $product_id
  * @param array $headers
  * @param array $body
  * @param array $items
  */
 public static function output_csv($product_id, $headers, $body, $items)
 {
     foreach ($body as $i => $data) {
         unset($body[$i]['comments']);
         foreach ($items[$i]['items'] as $item) {
             $item_meta = new WC_Order_Item_Meta($item['item_meta']);
             $item_meta = $item_meta->display(true, true);
             if (!empty($item_meta)) {
                 $meta = true;
                 $body[$i][] = $item['qty'] . 'x: ' . html_entity_decode($item_meta);
             } else {
                 $body[$i][] = $item['qty'];
             }
         }
     }
     if ($meta) {
         $headers['meta'] = __('Extra data', 'wc_product_vendor');
     } else {
         $headers['quantity'] = __('Quantity', 'wc_product_vendor');
     }
     $headers = apply_filters('wc_product_vendor_csv_headers', $headers, $product_id);
     $body = apply_filters('wc_product_vendor_csv_body', $body, $product_id);
     PV_Export_CSV::download($headers, $body, $product_id);
 }