Announcement

Collapse
No announcement yet.

Trying to fetch orders beginning at a number or those in the "New" folder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to fetch orders beginning at a number or those in the "New" folder

    Have been trying to fetch orders with this code snippet:

    ' Dim addS As String = (offs * 100).ToString
    Dim addS As String = "0" 'credentials("lastorderid")
    Try
    Dim req As WebRequest = WebRequest.Create("https://apirest.3dcart.com/3dCartWebAPI/v1/Orders/?limit=100&offset=" + addS)
    req.ContentType = "Content-Type: application/json;charset=UTF-8"
    req.Headers.Add("SecureURL: " + credentials("SecureURL").ToString())
    req.Headers.Add("PrivateKey: " + credentials("PrivateKey").ToString())
    req.Headers.Add("Token: " + credentials("Token").ToString())

    Any time I try to bump addS to a number greater than 0 I get an error. I need to get just the new orders.
    I suspect it is something to do with the parameters on the request line.

    As you can see, later in the code once we have the last order fetched, we'll update the lastorderid so next time the app is run, it begins at lastorderid+1


    Anyone able to provide a suggestion?

    Thanks in advance.

  • #2
    A simpler way...

    Only point your program at the "New" status orders. When you "process" an order in the New status, just move it to Processing status (can be done via the API). That way the next program run, you don't re-process the same orders again.

    Once they ship, have them move to Shipped status.

    I believe you will need to use the 'OrderStatusID' parameter. It's been a while since I looked at our code, but I think '0' is "New" by default, and "1" is Processing. You may have to play with it to make the determination.
    Last edited by Alupis; 10-09-2015, 03:23 PM.

    Comment


    • #3
      Actually, I was wrong. Status '1' is New, '0' must indicate "All" to the API.

      the table is "dbo_order_Status", which may appear just as "order_Status" depending on how you are viewing it.

      Here's what the one from our store looks like:

      ~
      id StatusID StatusDefinition StatusText Visible
      1 1 New New 1
      2 2 Processing Processing 1
      3 3 Partial Partial 1
      4 4 Shipped Shipped 1
      5 5 Cancel Cancel 1
      6 6 Hold Hold 1
      7 7 Not Completed Abandon Cart 1
      8 8 Custom 1 History 1
      9 9 Custom 2 Back Ordered 1
      10 10 Custom 3 Custom 3 0
      11 11 Unpaid Unpaid 1
      12 12 Recurring Recurring 0
      13 13 Review Review 0

      Comment


      • #4
        Thanks for the pointers. Especially the order_Status values. I am using the WebRequest.Create("https://apirest.3dcart.com/3dCartWebAPI/v1/Orders/?limit=100&offset=" + addS) method shown in my original post. Can I add a parameter on the end of that request like &status=1 ?

        I do understand that I'd have to restatus the orders as I pull them.

        Comment


        • #5
          RandyTucker yep, it appears you can just add it to your get request:

          https://apirest.3dcart.com/Help/Api/...fset_countonly

          I'd drop the offset= portion and instead use the orderstatus= portion. orderstatus defaults to a value of 0, which seems to imply "All" orders, and by default offset is set to 1, meaning no offset. So by dropping the offset= portion, the default is just fine.

          Then in your processing logic, when it's finished creating the order in your system, have it move the order in 3dCart to Processing (this way a failed orderCreate attempt doesn't cause you to miss orders, etc.).

          Comment


          • #6
            Alupis, Thanks for all the assist. Do you do development work? In the future I'd like to have someone who does this daily....work on my projects.

            Comment


            • #7
              Well, I'm currently working for a great company and don't have time for any contract work, however I'd encourage you to continue developing your skills as it really does unlock a whole new world of potential for your business. With enough code, almost anything is possible ;-P

              If you are really wanting to hire someone to do it and don't know any local dev shops, I could recommend Michael Dominick's company - Buccaneer Tech Inc (http://buccaneertech.com/). He specializes in mobile development, but he might be willing to do something different for a bit. I don't know if he's taking clients at the moment.

              Another option is to contact your local University and hire on some Computer Science students in their Junior or Senior year. Most won't have a lot of "real-world" experience and would love to do some projects to go on their resume and build a portfolio. My local University had an entire class dedicated to doing real-world work with real clients, often for very small fees or even sometimes for free (so the students can get more experience).

              Comment


              • #8
                RandyTucker I do a fair bit of contract work regarding the 3dcart api. If you ever need any help getting things along, I'd be happy to help.

                Comment


                • #9
                  Here's a recommendation to talk with jleclair on this. Great guy and does great work.

                  Comment

                  Working...
                  X