How to get list of orders with php ?

WPPizza – A Restaurant Plugin for WordPress Support General Support How to get list of orders with php ?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36533
    alierdem
    Participant

      hello there
      im trying to develop a plugin but i couldnt managed to get orders in wp pizza, what is the right way to do this ?
      also i want to add orders programmatically
      i tried to get it from the database table but with that way i cant get order status etc.

      i couldnt find anything on docs, what class/file/document should i look into ?

      #36570
      Olly
      Admin & Mod

        i’m afraid , there isnt really a simple way to do this as virtually all queries will only ever return a restricted dataset
        (either by user id , or by order id , or limited by pagination etc etc)

        that said, i can see the usefulness of making this available in some circumstances , and will add an easy to use wrapper function in one of the next updates

        #36573
        alierdem
        Participant

          so, how can one get users orders ? i couldnt find it in documentation
          i can start from there and implement my need, and share final code with everyone

          #36574
          alierdem
          Participant

            nevermind i could to it
            WPPIZZA() -> db -> get_orders_orderhistory(false, -1, 10, 1);
            you can also do it with this.
            i hope wp pizza had better documentation and little bit better quality of code.

            #36575
            Olly
            Admin & Mod

              that’s just offensive
              feel free to write your own plugin, maintain it over the years keeping things backwards compatible for old php, mysql versions while also accounting for endless variations of server setup, adding forever new things for your 1000’s of users , reply to literally thousands of support requests / emails / forum topics and then come back to me complaining

              in any event , that get_orders_orderhistory is a leftover from v2 and is only used in the order history and will probably be removed at some point in favour of a wrapper that will then use the fetch_order_details which will then allow queries that are not as restrictive as they are at the moment with the output being formatted as opposed to just the raw data and a bunch of other options

              #36577
              Olly
              Admin & Mod

                in fact i would suggest you simply use your own query

                ie. something like

                
                global $wpdb;
                $orders = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix . WPPIZZA_TABLE_ORDERS." WHERE payment_status='COMPLETED'  ORDER BY order_date DESC");

                as opposed to relying on internal functions that might change or get removed at any time (unless they are documented here https://docs.wp-pizza.com/developers/?section=filters-actions-functions , hence why there are a bunch of wrappers available the list of which gets expanded on an as needed basis )

              Viewing 6 posts - 1 through 6 (of 6 total)
              • The topic ‘How to get list of orders with php ?’ is closed to new replies.