We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Final version 2 of shopX updated on first post.

    The included shipping option TVs don’t do any calculations; that will be dependent on how shipping charges are calculated for the option you’re using. Either put the calculation code in the TV before the code for the option radio button, or include() a php file with the calculations.

    The included COD payment module sort of works; there’s a lot of things wrong with it, but it should give you the idea of how a payment module works. Again, put the code right in the TV, or maybe better, include() a php file with the code.

    The ShopCheckout snippet and the two Option TVs are placed in the checkout document. The ShopCart snippet goes in the sidebar (or wherever you want it...) in the site template. Layout and styling are up to you!

    The other TV tags are put in the appropriate place in the appropriate Option TVs. They are commented, and samples are already there.

      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
      • 7455
      • 2,204 Posts
      I like the fact that to remove an item you can enter negative values (-1)

      would it be posible to use the enter-key to "add to cart" now this does not work

      Increadible nice work Susan!!
        follow me on twitter: @dimmy01
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You can also enter 0 to remove a line item from the cart.

        Enabling the "enter" key to add an item is quite do-able, since that is the form’s submit button. I don’t know how at the moment, however.
          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
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          A small problem has been brought to my attention. I’m using the Description field to store the price, but the NewsListing snippet does not get the description field from the database or set it as a placeholder. I had hacked it to add that feature, and forgot about it! So it needs to be added to three places, in the $fields list in the main query, and in the $fields and $values arrays where the placeholders are set.

          $resource = $modx->$callby($resourceparent, $sortby, $sortdir, $fields='id, pagetitle, longtitle, description, introtext, content, createdon, createdby, hidemenu');
          ...
          $fields = array('[+title+]','[+longtitle+]','[+description+]','[+summary+]','[+link+]','[+author+]','[+date+]','[+id+]');
          $values = array($resource[$x]['pagetitle'],$resource[$x]['longtitle'],$resource[$x]['description'],$summary,$link,$username,strftime($date, $resource[$x]['createdon']),$resource[$x]['id']);
          


          (sparselogic, if you read this, your inbox is full...)
            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Discovered another bug. The variable "id" that is being passed around for the ID of the item in question is used by the parser to change the page to that page id whenever you "add to cart" if Friendly URLs are NOT being used. This is not an issue if you are only showing the add to cart form on the individual item pages, but if you are showing multiple items with add to cart forms on one page, it’s a show stopper.

            So, I need to go through the script from the add to cart form to the plugin to the snippets and change that variable.

            [later...] Ok, went through the chunk used by NewsLister, the place in NewsLister where the [+id+] placeholder is defined, the chunk used as ShopFooter, the three snippets and the plugin, changing all the occurances of ’id’ to ’itemid’. Problem solved. Probably didn’t need to change everything, but I didn’t feel like messing around with it. I’ll attach a modified version of the package shortly.
              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
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Hah! Swatted another bug for pages with Add to Cart buttons for more than one item! When you Clear Cart, it clears the cart and refreshes the page...with the same query string in the URL, so adding items first clears the cart then adds the latest item!

              I added a sendRedirect to the block of code clearing the cart in the plugin.

              // clear the cart
              if (isset($_GET['a']) && $_GET['a'] == 'clear') {
                unset($_SESSION['orders']);
                unset($_SESSION['order']);
                $modx->sendRedirect($modx->makeURL($modx->documentIdentifier));
              }
              
                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
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                shopX now uses the latest version of NewsListing with no modifications. It’s all in the arguments and the display template. Great work, guys!
                  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
                  • 25663 MODX Staff
                  • 12,272 Posts
                  LOL ... I was just talking to Mark about one more update for 0.9.1 ... cross that one off the list!
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Version 2.1 attached to the first post. More ideas, more beating, more bugs to swat, please!
                      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
                      • 28122
                      • 51 Posts
                      Wow. I’m impressed.
                      This. Flat. Rocks!
                      And the revision schedule puts commercial offerings to shame... smiley