We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    I just ran across this super simple shopping cart.

    http://www.opendesigns.org/forum/discussion/1252/2/who-can-make-me-a-flat-file-shopping-cart-ill-pay/#Comment_15453

    I was thinking that it could likely be added into MODx rather easily. Just transform the different parts into templateable chunks, use ditto to generate the product list file that it requires, and for good measure a dose of ajax love. Anyone think they could quickly turn this into something useful?

    Here is one of the designers easily adapting it to a template:

    http://wfiedler-online.de/shop/
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 14050
      • 788 Posts
      This is just my first attempt at making them interact with each other:

      Ditto generates the product list:

      http://cmssandbox.com/MODx096/index.php?id=49

      Then in filecart.php set the "PRODUCTS_FILE_PATH" to the above address.

      Next modify one of the functions to allow getting the file from a URL:

      function LoadProductsFromFile() {
      $contents = file_get_contents(PRODUCTS_FILE_PATH);
      if ($contents) {
      //Read it
      $Products_array = explode(’;’,$contents);
      foreach($Products_array as $value)
      {
      $Product = explode(PRODUCTS_FILE_DELIMITER,$value);
      $cartitem = array($Product[ID_COLUMN], $Product[NAME_COLUMN], $Product[PRICE_COLUMN], $Product[DESCRIPTION_COLUMN], 0);
      $items[$Product[ID_COLUMN]] = $cartitem;
      }

      $_SESSION[CART] = $items;
      }
      }

      Example:

      http://cmssandbox.com/PHPCart/index.php?cartaction=add&cartitem=BEER1&carttoken=1750010917

      This is just my first attempt at having the two interact.

      I imagine with using ManagerManager to hide some of the fields, creating the right TVs...and the added payment gateway they plan on implementing...that this could prove really useful.
        Jesse R.
        Consider trying something new and extraordinary.
        Illinois Wine

        Have you considered donating to MODx lately?
        Donate now. Every contribution helps.
        • 14050
        • 788 Posts
        Here is the cart working in a primitive way:

        http://cmssandbox.com/MODx096/index.php?id=48

        I am trying to abstract it out further. I imagine eForm can be utilized for the Checkout Process.
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
          • 14050
          • 788 Posts
          Here is the link to a product page:

          http://cmssandbox.com/MODx096/index.php?id=50

          As you can see, you can click to the link over and over again to add products. The remaining products are over in the sidebar, try adding them.

          This is all accomplished with the snippet processing the cart elements,called like this:

          [!sss!]

          Ditto to generate the product list that the snippet needs and Wayfinder to generate the list of products in the sidebar. Obviously you could use ditto to create the product call and this snippet to handle adding stuff to the cart.

          Here is a screencapture of the backend configuration. You can see where it is pulling the items from "Title," "Longtitle," "Description," and "Introtext." This is where ManagerManager and TVs could come in handy. You could create custom TVs for all the necessary fields and then use the other fields for their original purpose so that you can setup your catalog with ditto.
            Jesse R.
            Consider trying something new and extraordinary.
            Illinois Wine

            Have you considered donating to MODx lately?
            Donate now. Every contribution helps.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Now all you need to do is make that an Ajax request so it doesn’t have to refresh the page!

            Just kidding! That’s really nice grin
              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
              • 14050
              • 788 Posts
              Ajax request would be awesome. Any one care to make the necessary modifications? I plan to wait to package anything up for everyone’s consumption until they finish the Payment Gateway class.
                Jesse R.
                Consider trying something new and extraordinary.
                Illinois Wine

                Have you considered donating to MODx lately?
                Donate now. Every contribution helps.
                • 26435
                • 1,193 Posts
                Wicked.

                -sD-
                The Good Doctor.
                  Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                  All of the above... in no specific order.


                  I send pointless little messages
                  • 14050
                  • 788 Posts
                  Just an update that I now have the cart templateable:

                  http://cmssandbox.com/MODx096/index.php?id=50

                  As of this moment, it is two snippets. One snippet automagically generates an add link for the product. Essentially, you would create a document that is a product page, and then call the snippet where you want a link for "Add to Cart" to be. The next snippet shows the actual cart you can send a template to the snippet with the following placeholders:

                  [+id+]
                  [+name+]
                  [+description+]
                  [+price+]
                  [+quantity+]
                  [+quantityprice+]
                  [+addlink+]
                  [+removelink+]

                  I am still working out how I want to make the cart total and the "clear cart" link templateable. Right now, after the contents of the cart are output (via user selected template) the total and clear cart link are echoed in the snippet. Anyone wanting access to what I have done to help contribute would be nice. Maybe someone with some AJAX abilities to make this a little more snazzy. I think once we are done, this will offer a really nice solution for Super Simple Shopping carts that only need a basket with a checkout that goes through something like PayPal, and sends an e-mail to the Shop Owner so the order may be fullfilled.

                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.
                    • 29181
                    • 480 Posts
                    Quote from: jesster444 at Sep 18, 2007, 01:26 AM

                    I think once we are done, this will offer a really nice solution for Super Simple Shopping carts that only need a basket with a checkout that goes through something like PayPal, and sends an e-mail to the Shop Owner so the order may be fullfilled.

                    I agree, this could be a nice lightweight solution.

                    Quote from: jesster444 at Sep 18, 2007, 01:26 AM

                    Anyone wanting access to what I have done to help contribute would be nice. Maybe someone with some AJAX abilities to make this a little more snazzy.

                    I may be able to take a look into some AJAX goodness over the weekend / at the beginning of next week with a little luck.

                    Great work Jesster!

                    All the best,
                    Taff
                      Adrian Lawley: www.adrianlawley.com
                      • 14050
                      • 788 Posts
                      Alright. I think I have the whole system under control. You can add items to the cart, remove items from the cart, and checkout via eForm. You can see it in action here:

                      http://cmssandbox.com/MODx096/index.php?id=50

                      It is just the standard contact form included with the default install with a custom function call in the eForm call so it sends an e-mail with the car contents. Try it out. When click checkout, it will send the cart contents to you and the shopkeeper, and then will clear the cart. Now just waiting until they implement the payment gateway, and I will package this up and let people do with it what they want.
                        Jesse R.
                        Consider trying something new and extraordinary.
                        Illinois Wine

                        Have you considered donating to MODx lately?
                        Donate now. Every contribution helps.