Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

wordpress plugin

Options
  • 12-11-2016 8:08pm
    #1
    Registered Users Posts: 6,252 ✭✭✭


    I'm using woo commerce on a site which naturally sells stuff to people. What I want to be able to do is show each individual user their purchase history on a graph of volume over time. Is there a plugin available that does this?


Comments

  • Registered Users Posts: 6,501 ✭✭✭daymobrew


    I'm using woo commerce on a site which naturally sells stuff to people. What I want to be able to do is show each individual user their purchase history on a graph of volume over time. Is there a plugin available that does this?
    I don't know but it should not be too difficult to do - WooCommerce has a fantastic amount of hooks and filters that makes it easy to extend.


  • Registered Users Posts: 6,252 ✭✭✭Buford T Justice


    daymobrew wrote: »
    I don't know but it should not be too difficult to do - WooCommerce has a fantastic amount of hooks and filters that makes it easy to extend.

    Where's the best place to find information about this? I have no experience with wordpress.


  • Registered Users Posts: 241 ✭✭fcrossen


    Where's the best place to find information about this? I have no experience with wordpress.
    It is likely you will need to code a custom plugin. Feel free to PM me if you need help or advice with this.


  • Registered Users Posts: 6,501 ✭✭✭daymobrew


    Where's the best place to find information about this? I have no experience with wordpress.
    I find much of my information by reading the WooCommerce source code though that requires that you are comfortable with PHP.

    If you have no experience with WordPress (and I guess no experience with WooCommerce), you might be best to get a custom plugin made or look through CodeCanyon's 955 WooCommerce plugins to find a fit.


  • Registered Users Posts: 6,252 ✭✭✭Buford T Justice


    I develop professionally in php but using an MVC framwork for creating apps from scratch. Also studying an honours degree in computing. This is a side project I'm looking to do for someone. I may well have to roll my own, but there may be something out there that already does it.

    As I say, my downfall is I know zero about wordpress. I've never used it and so I'm not familiar with it in any way such as available functions, how to create plugins etc......


  • Advertisement
  • Registered Users Posts: 241 ✭✭fcrossen


    I develop professionally in php... ...I know zero about wordpress. I've never used it and so I'm not familiar with it

    There is a learning curve - Wordpress is a quirky beast - but if you have PHP experience you'll be fine. Check out:
    - https://codex.wordpress.org/Plugin_API/
    for the basics. Read up on action and filter hooks. After that you just need to know what hooks to use. Look at:
    - http://adambrown.info/p/wp_hooks
    for a comprehensive list.


  • Registered Users Posts: 6,501 ✭✭✭daymobrew


    As you will be dealing with changing the WooCommerce area, you'll need the WooCommerce Action and Filter Hook Reference.

    If you write a brief spec maybe someone will write a bit of code to start you out.


  • Registered Users Posts: 6,252 ✭✭✭Buford T Justice


    daymobrew wrote: »
    As you will be dealing with changing the WooCommerce area, you'll need the WooCommerce Action and Filter Hook Reference.

    If you write a brief spec maybe someone will write a bit of code to start you out.

    Simple enough concept really. query users sales from woo commerce db by type and use chartjs or similar to plot a line graph of sales over time, potentially using an api endpoint for chartjs to access.


  • Registered Users Posts: 6,501 ✭✭✭daymobrew


    Simple enough concept really. query users sales from woo commerce db by type and use chartjs or similar to plot a line graph of sales over time, potentially using an api endpoint for chartjs to access.
    There's a lot of gaps in that spec :-)
    Do you want a new tab in the "My Account" section or the graph added at the bottom of the "My Orders" tab?
    Should the graph be monthly or weekly or yearly?


  • Registered Users Posts: 6,501 ✭✭✭daymobrew


    Here's a tiny plugin that appends info to the My Orders tab (see attached screenshot).
    https://gist.github.com/damiencarbery/b01895dd847acc0d7630dcfee35f02e2

    The code simply goes through each order and gets the total spend for that customer.
    Your code would have to examine the date of each order and decide how to store that info. Probably not hard, just a good bit of grunt work to organise the data and convert it into something for chartjs.


  • Advertisement
  • Registered Users Posts: 241 ✭✭fcrossen


    @Buford: For some reason boards will not allow me to reply to your PM. The wpdb class allows access to the MySQL database. See
    - https://codex.wordpress.org/Class_Reference/wpdb

    Check out https://codex.wordpress.org/Creating_Tables_with_Plugins if you need to create tables.


  • Registered Users Posts: 6,252 ✭✭✭Buford T Justice


    daymobrew wrote: »
    There's a lot of gaps in that spec :-)
    Do you want a new tab in the "My Account" section or the graph added at the bottom of the "My Orders" tab?
    Should the graph be monthly or weekly or yearly?

    Yup, Got your pm's.

    The time period for the graph isn't important, but for argument sake lets say its annually to start with. This could be modified later as part of an api query, or by the mysql query that generates the results.
    The layout, as its been communicated to me was that it would be a widget that would sit on the users dashboard page along with a few other custom ones and a weather widget.... Not sure how that sits with wordpress though

    in MYSQL the query would resemble something like
    SELECT ([I]whatever fields[/I], WEEK([I]date field[/I]) AS week) 
    FROM ([I]whatever table[/I]) 
    WHERE [I]user_id[/I] = ([I]user id[/I]) 
        AND [I](sale date[/I]) >= (date)
        AND ([I]sale date[/I]) <= date 
    GROUP BY (date, or week or some other derived field )
    
    

    Using italics to assume what the db field names would be


  • Registered Users Posts: 6,501 ✭✭✭daymobrew


    I wouldn't write a custom SQL query as WooCommerce has an API to retrieve a customer's orders - wc_get_orders(). I would loop through that, get the date and order total. For an annual period I would parse the date and group by year total.

    If you write a custom query there is a chance that changes by WooCommerce will break your code.

    For speed I suggest storing the order total data in a custom field so that it does not have to be recalculated on each page load.


Advertisement