public function get_wooc_product_data() { global $post, $the_product; $user_data = $this->user_data; $user_email = $user_data->email; $user_ID = $user_data->user_id; $orders_data = array(); $order_products = array(); include_once dirname(WC_PLUGIN_FILE) . '/includes/admin/class-wc-admin-post-types.php'; $CPT_Product = new WC_Admin_Post_Types(); $args = array('numberposts' => -1, 'post_type' => 'product', 'post_status' => 'publish'); #$products = get_posts( $args ); $products = wcrm_customer_bought_products($user_email, $user_ID); foreach ($products as $prod) { $post = get_post($prod->ID); $the_product = wc_get_product($prod->ID); if (!wc_customer_bought_product($user_email, $user_ID, $prod->ID)) { # continue; } $o['ID'] = $prod->ID; ob_start(); $CPT_Product->render_product_columns('thumb'); $o['thumb'] = ob_get_contents(); ob_end_clean(); ob_start(); $edit_link = get_edit_post_link($prod->ID); $title = _draft_or_post_title(); echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>'; $o['name'] = ob_get_contents(); ob_end_clean(); ob_start(); $CPT_Product->render_product_columns('sku'); $o['sku'] = ob_get_contents(); ob_end_clean(); $o['number_purchased'] = $prod->items_count; $o['value_purchases'] = wc_price($prod->line_total); $orders_data[] = $o; } return $orders_data; }
public function get_products_purchased() { return wcrm_customer_bought_products($this->email, $this->user_id); }