Announcement

Collapse
No announcement yet.

Modifying an order on the admin page

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

    Modifying an order on the admin page

    Hi folks, got a tricky problem today; I'll see if I can keep the explanation simple.

    I've written a module that adds a BasketCharge to the order during checkout (never mind why; I'm trying to keep this simple). That part is working fine. The client sometimes makes changes to an order, such as changing the quantity of an item, on the Order Processing admin page. When that happens, the amount of the BasketCharge needs to be adjusted. I've written some Module_Order_Content code that provides a button the client can click, which triggers the module to examine the changed order and update the BasketCharge. But the client asked if this updating can happen automatically whenever they make changes to the order; and that part has me stumped.

    I tried using the not_orderitem API to update the BasketCharge whenever they make changes to an item, but it doesn't work as expected. Apparently there's some kind of sandboxing going on, so that the module's changes don't have the expected result. Apparently the store makes a copy of the order in a variable, so that some of my module's changes end up getting overwritten.

    It's possible that, with some more trial-and-error, I could figure out what's happening internally, so that I could have my module do some extra math and DB updates to get the desired result. But I'm reluctant to go too far down that road, when I have no access to the admin.mv code to find out what's really going on.

    Do you have any experience with this sort of thing? Any advice, work-arounds, etc.?

    Thanks; hope everyone's staying healthy --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    Hey, Kent,

    UPDATED: Maybe there are some possibilities using the Order Workflow APIs...

    FYI, I haven't used the Module Order Content functions, so the following may be incorrect/incomplete.

    I'm not sure my thoughts will be of any help, but who knows. Not having a public Admin API detracts from being able to be productive for these scenarios. Still, for the Order tables, there may not be any API regardless because these tables are, what I characterize as, dumb. The only real connection to other data is "payment" data. ( I am sure you understand this, I just mentioned this to supply context to other readers). What I think this translates to, the data in the order tables you need to adjust is just numbers and/or text and you need to redefine what that data is when you load the order data with the intent of doing "something" to it.

    My thought for a solution that you probably figured out already, make a Utility screen admin that can make the adjustments instead of in the Order Processing screens since it appears that are no functions to execute(assumed of course since we don't know what runs) (Maybe this is where the Mobile Order Content enters the picture?) Luckily, there are Order_Load functions to load data from the order tables. You should be able to modify the data and update the tables from there. Doing this admin in Utils would represent doing the basket changes where all the data gets updated automatically. I know, maybe this kind of solution is more complicated than it needs to be?

    Scott
    Last edited by ids; 04-23-20, 11:30 AM.
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    Comment


      #3
      Hi Scott, Yes, if necessary, I can write a whole new admin page to handle this. That would be a lot of work for me; and it might make the client's workflow more complex, when the whole idea is to simplify it. But Thanks for the suggestion --
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment


        #4
        The client's workflow is a Blackbox for us/me. I have no context for it. It's irrelevant though IMO. I understand the issue, not having to click the button to re-process the order is best. What if the "User" forgets to? Useless human error when a perfectly good computer is being underutilized. Until we know more, I think you have made it as simple and straight forward as possible. Hopefully, a Merchant Core developer can weigh in on a function that could help process/modify numbers in the order tables, from your function, because we already know that works.

        Brainstorming: could a Batch module be used to reprocess the orders?

        Scott
        Need to offer Shipping Insurance?
        Interactive Design Solutions https://www.myids.net
        MivaMerchant Business Partner | Certified MivaMerchant Web Developer
        Competitive Rates, Custom Modules and Integrations, Store Integration
        AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
        My T-shirt Collection is mostly MivaCon T-shirts!!

        Comment


          #5
          How does one add a BasketCharge to an Order? I thought you could only add a BasketCharge to a Basket (before it was converted to an Order). Or maybe you are using BasketCharge to mean OrderCharge?
          Gordon Currie
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment


            #6
            Sorry, I used the wrong term. The module adds a BasketCharge to the customer's basket during checkout. Once the order is completed, of course, the BasketCharge is converted to an OrderCharge. That's what the module needs to modify.
            Kent Multer
            Magic Metal Productions
            http://TheMagicM.com
            * Web developer/designer
            * E-commerce and Miva
            * Author, The Official Miva Web Scripting Book -- available on-line:
            http://www.amazon.com/exec/obidos/IS...icmetalproducA

            Comment


              #7
              So you have tried using OrderCharge_Update_Amount() and it doesn't work? Maybe you have to reload the order in order to retrieve the new values from the database.
              Gordon Currie
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                Actually, I wrote my own UPDATE query instead of using the library function. But OrderCharge_Update_Amount() is a low-level function; it doesn't call any other functions, modify other tables, etc.
                Kent Multer
                Magic Metal Productions
                http://TheMagicM.com
                * Web developer/designer
                * E-commerce and Miva
                * Author, The Official Miva Web Scripting Book -- available on-line:
                http://www.amazon.com/exec/obidos/IS...icmetalproducA

                Comment

                Working...
                X