We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi, I have a project coming in where I need to hook in a stock ordering system to a MODx website. The stock ordering system will sit behind a pass-worded area and present the user with a long list of products they an order on a per week basis, indicating how many of each item they need for each day of that week. The products available to order will be CMS controlled - so fed probably by a getResources call to display each of the products included in some folders in the site tree. I guess I will use getResource tpl to include a <form> bit of code for that product and use formit to collect all the data from the stock ordering form. So after the user has indicated they want bananas, 3 of on Tuesday, 5 of on Sunday and Coffee, 1 of on MOnday, 3 on Wednesday and 2 on Saturday - The user will then click on the ORDER THESE button, then I want to hide all the un-ordered products where they can make any final amendments to the volume of products ordered, click to add more products - jumping them back to the first stock ordering view, or click on the CONFIRM button which will then post the details of the order form via email to a designated email address. I would also like the order stored in MODx in someway if possible???

    Does this all sound feasible within MODx? It's kind of like an ecommerce solution without the payment bit - as the order just gets sent to the HQ for them to order on behalf of the ordering team.

    Any tips / thoughts on how to achieve this?

    The main bit I am not sure of a solution on, is the review your order view - which hides all products which have not been selected to order - any tips on how to hide these products?


    Cheers,

    dubbs.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would just adapt one of the existing ecommerce extras, like SimpleCart or MiniShop2.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 8168
        • 1,118 Posts
        Quote from: sottwell at Dec 29, 2015, 03:32 PM
        I would just adapt one of the existing ecommerce extras, like SimpleCart or MiniShop2.

        OK thanks for the idea Susan - I will have a look at those, I see that SimpleCart is now a paid addon.

        I think the getResources solution will work to generate the order form well - my main worry is how to do the order review view. I'd prefer to bespoke create the solution so it works exactly as I want it - tweaking an ecommerce solution might work - but here, in my usage - each product can be ordered multiple times on different days - so doesn't fit the usual ecommerce model for a product. e.g. see below:

        Mon Tue Wed Thur Fri Sat Sun

        Diary
        Milk 0 1 0 3 1 2 0
        Cheese 1 0 2 0 0 2 1
        Cream 0 0 0 0 0 0 0

        Meat
        Chicken 1 0 1 1 1 0 2
        Beef 0 0 0 0 0 0 0


        Then on clicking to submit order, the user is presented with just the products they have opted to order in a review view - e.g. as below:

        Mon Tue Wed Thur Fri Sat Sun

        Diary
        Milk 0 1 0 3 1 2 0
        Cheese 1 0 2 0 0 2 1

        Meat
        Chicken 1 0 1 1 1 0 2
          • 3749
          • 24,544 Posts
          The results should be in the $_POST array, so it shouldn't be too difficult to display them. The trick will be handling the case where the user wants to change the order after reviewing it.

          I would think that if the original form is clear enough, you wouldn't need the review. As a compromise, you could use JS to show a confirmation dialog when Submit is clicked and just abort the submission if the user doesn't confirm it.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 8168
            • 1,118 Posts
            Quote from: BobRay at Dec 29, 2015, 04:10 PM
            The results should be in the $_POST array, so it shouldn't be too difficult to display them. The trick will be handling the case where the user wants to change the order after reviewing it.

            I would think that if the original form is clear enough, you wouldn't need the review. As a compromise, you could use JS to show a confirmation dialog when Submit is clicked and just abort the submission if the user doesn't confirm it.

            Thanks Bob - user wont be able to change order when reviewing the order - all they can do is change numbers of items ordered on the various days. How would I access the $_POST array and display its contents via JS?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              If you use FormIt, you can tell FormIt to store the field values for use in a second page, like a thank-you or acknowledgement page. The second page uses the FormitRetriever snippt.

              https://rtfm.modx.com/extras/revo/formit/formit.formitretriever
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 3749
                • 24,544 Posts
                JS doesn't have access to the to the $_POST variables (though it can read $_GET variables in the URL), but it doesn't matter because the form hasn't actually been submitted at that point.

                What I was describing goes like this:

                1. User fills or edits the form
                2. User clicks on the Submit button
                3. The onSubmit for the button pops up an "are you sure" dialog in a location that doesn't block the form (or the dialog can be dragged).

                If the user clicks yes, the form is submitted -- email sent, whatever.
                If the user clicks no, the dialog disappears and the use is still looking at the form, which takes them back to step 1.

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 8168
                  • 1,118 Posts
                  Quote from: BobRay at Dec 30, 2015, 01:10 PM
                  JS doesn't have access to the to the $_POST variables (though it can read $_GET variables in the URL), but it doesn't matter because the form hasn't actually been submitted at that point.

                  What I was describing goes like this:

                  1. User fills or edits the form
                  2. User clicks on the Submit button
                  3. The onSubmit for the button pops up an "are you sure" dialog in a location that doesn't block the form (or the dialog can be dragged).

                  If the user clicks yes, the form is submitted -- email sent, whatever.
                  If the user clicks no, the dialog disappears and the use is still looking at the form, which takes them back to step 1.


                  Thanks bob - but the form is going to be very long so I need a 2nd view which just shows the items which have been ordered - I will explore Susan's idea.
                    • 3749
                    • 24,544 Posts
                    Just a thought -- the OnSubmit JS could get the results from the DOM and show the summary in the confirmation dialog.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      It also might be interesting to get the form field values and store them in the browser disk storage, then you can get them out again whenever you want them.

                      https://plugins.jquery.com/tag/localstorage/
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org