The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Create WordPress Plugin

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #148544

    I’m playing around with creating some reports for a friend of mine. He is using WooCommerce and I’ve read up on where the data is stored and have written the MySQL statement to retrieve the data. I’ve tested the statement using MySQL workbench and the statement returns all the content I need.

    I’m trying to figure out how to take the data returned and display it to a table for my client to be able to export out into a Excel document. Any help would be great.

    This is my code to pull the data and store it for later use.

    function Sales_Report()
    global $wpdb;
    $p = $wpdb->posts;
    $pm = $wpdb->postmeta;
    // $reports = $wpdb->get_rows("SELECT * FROM $wpdb->posts WHERE post_type = 'shop_order'");
    $sells = $wpdb->get_rows("SELECT $p.ID, $p.post_date, $pm.post_id, $pm.meta_key, $pm.meta_value FROM $p, $pm WHERE $p.post_type = 'shop_order' AND $ = $pm.post_id");
    echo $sells;

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.