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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

wordpress plugin

  • 12-11-2016 7:08pm
    #1
    Registered Users, Registered Users 2 Posts: 6,262 ✭✭✭


    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, Registered Users 2 Posts: 6,571 ✭✭✭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, Registered Users 2 Posts: 6,262 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 6,571 ✭✭✭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, Registered Users 2 Posts: 6,262 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 6,571 ✭✭✭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, Registered Users 2 Posts: 6,262 ✭✭✭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, Registered Users 2 Posts: 6,571 ✭✭✭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, Registered Users 2 Posts: 6,571 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 6,262 ✭✭✭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, Registered Users 2 Posts: 6,571 ✭✭✭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